From dd684349c67c988ef19707cb65e637b6906fac75 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Fri, 8 Jul 2022 19:54:42 +0200 Subject: Solved some new problems --- codechef/RacingHorses/main | Bin 0 -> 44616 bytes codechef/RacingHorses/main.cpp | 22 ++++++++++++++++++++++ codechef/RacingHorses/main_input0.txt | 3 +++ codechef/RacingHorses/main_output0.txt | 1 + 4 files changed, 26 insertions(+) create mode 100755 codechef/RacingHorses/main create mode 100644 codechef/RacingHorses/main.cpp create mode 100644 codechef/RacingHorses/main_input0.txt create mode 100644 codechef/RacingHorses/main_output0.txt (limited to 'codechef/RacingHorses') diff --git a/codechef/RacingHorses/main b/codechef/RacingHorses/main new file mode 100755 index 0000000..a071dd7 Binary files /dev/null and b/codechef/RacingHorses/main differ 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 + +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 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; + } +} diff --git a/codechef/RacingHorses/main_input0.txt b/codechef/RacingHorses/main_input0.txt new file mode 100644 index 0000000..3142f24 --- /dev/null +++ b/codechef/RacingHorses/main_input0.txt @@ -0,0 +1,3 @@ +1 +5 +4 9 1 32 13 \ No newline at end of file diff --git a/codechef/RacingHorses/main_output0.txt b/codechef/RacingHorses/main_output0.txt new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/codechef/RacingHorses/main_output0.txt @@ -0,0 +1 @@ +3 \ No newline at end of file -- cgit v1.2.3