Skip to content

Instantly share code, notes, and snippets.

@chermehdi
Created September 28, 2016 11:45
Show Gist options
  • Save chermehdi/85260e41f0cb2926233e856394693530 to your computer and use it in GitHub Desktop.
Save chermehdi/85260e41f0cb2926233e856394693530 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define INF 9999999
#define MAX 1000000
typedef long long ll;
using namespace std;
int n,t;
ll tab[MAX];
int main() {
cin>>n;
while(n--){
cin>>t;
for(int i=0;i<t;i++){
cin >> tab[i];
}
sort(tab, tab + t);
int min = INF;
for(int i = 0; i < t - 1; i++){
if(abs(tab[i] - tab[i+1]) < min)
min = abs(tab[i] - tab[i+1]);
}
cout << min << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment