Created
September 28, 2016 11:45
-
-
Save chermehdi/85260e41f0cb2926233e856394693530 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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