Skip to content

Instantly share code, notes, and snippets.

@ravichandrae
Created January 24, 2017 06:45
Show Gist options
  • Save ravichandrae/02528caff5aead78f660d69894bf2798 to your computer and use it in GitHub Desktop.
Save ravichandrae/02528caff5aead78f660d69894bf2798 to your computer and use it in GitHub Desktop.
ANUARM: A codechef problem
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main() {
int t;
cin >> t;
while(t--) {
int n,m;
cin >> n >> m;
vector<int> max_nums(n);
int min_m = n, max_m = -1;
int i;
for(i = 0; i < m; i++) {
int ind;
cin >> ind;
min_m = min(min_m, ind);
max_m = max(max_m, ind);
}
for(int i = 0; i < n; i++) {
cout << max( abs(i-max_m), abs(i-min_m) ) << " ";
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment