This is the problem : https://codeforces.com/contest/567/problem/A
Summary of Problem: Basically there are different cities on a number line and we must calculate the maximum and minimum cost of sending a mail from one city to any other city on the list. The cost of sending mail is exactly equal to the distance between two given cities.
This is my code:
#include <iostream>
#define ll long long
using namespace std;
int main () {
ll n;
int a[n];
int b[n];
ll maxx;
ll minn;
for (ll i=0; i<n; i++) {
cin >> a[i];
}
ll i=0;
for (ll i=0; i<n; i++) {
ll j=0;
for (ll j=0; j<n; j++) {
ll b[i]={a[j]-a[i]};
}
sort (b, b+n);
ll minn= b[1];
ll maxx= b[n];
cout << minn << maxx;
}
}
I am open to learning anything new that would be useful for me, feel free to make suggestions since I am still a beginner.