CodeChef::HORSES

 

#include <bits/stdc++.h>
using namespace std ;

int main (){
int t ;
cin >> t ;
while (t--){
int n ;
cin >> n ;
int s[n];
for (int i = 0; i < n; ++i) {
cin >> s[i];
}
sort(s,s+n);
long long int smallest{INT64_MAX};
for (int i = 0; i < n - 1; ++i) {
if (s[i+1] - s[i] < smallest){
smallest = s[i+1] - s[i];
}
}
cout << smallest << '\n';

}
return 0;
}

Comments

Popular posts from this blog

CodeChef::CSUB

How Recursion Works?

Atcoder Educational Dp contest :: C vacation