aboutsummaryrefslogtreecommitdiff
path: root/codechef/RacingHorses/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'codechef/RacingHorses/main.cpp')
-rw-r--r--codechef/RacingHorses/main.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/codechef/RacingHorses/main.cpp b/codechef/RacingHorses/main.cpp
new file mode 100644
index 0000000..1da09f4
--- /dev/null
+++ b/codechef/RacingHorses/main.cpp
@@ -0,0 +1,22 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int n;
+ cin >> n;
+ vector<int> v(n);
+ for(int &x : v) cin >> x;
+ sort(v.begin(), v.end());
+ int mn = 1e9;
+ for(int i = 0; i < n - 1; i++) {
+ mn = min(mn, abs(v[i] - v[i + 1]));
+ }
+ cout << mn << endl;
+ }
+}