output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> int main() { int a[1000]; int b, i, j, c, m, m1, k; scanf("%d", &b); for (i = 0; i < b; i++) { scanf("%d", &c); for (j = 0; j < c; j++) { scanf("%d", &a[j]); } m = abs(a[0] - a[1]); for (j = 0; j < c - 1; j++) { for (k = j + 1; k < c; k++) { m1 = ...
### Prompt Please formulate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } sort(v.begin(), v.end()); int mx = v[1] - v[0]; for (int i = 0; i < n - 1; i++) { mx = min(mx, v[i +...
### Prompt Your task is to create a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t-- > 0) { int len; cin >> len; int ar[len]; int min = INT_MAX; for (int i = 0; i < len; i++) cin >> ar[i]; sort(ar, ar + len); for (int i = 0; i < len - 1; i++) { if (ar[i + 1] - ar[i] < min) min ...
### Prompt Generate a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int diff(int arr[], int n) { sort(arr, arr + n); int diff = INT_MAX; for (int i = 0; i < n - 1; i++) if (arr[i + 1] - arr[i] < diff) diff = arr[i + 1] - arr[i]; return diff; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n...
### Prompt Generate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vector<int>>; using vp = vector<pii>; using vs = vector<string>; using qi = queue<int>; using qp = queue<pii>; using pqi = priority_queue<int>; using pqim = p...
### Prompt Develop a solution in Cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; vector<int> arr; cin >> n; while (n--) { int input; cin >> input; arr.push_back(input); } sort(arr.begin(), arr.end()); int max = arr[arr.size() - 1]; for (int i = 0; ...
### Prompt Please create a solution in Cpp to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int T, n, ar[100]; cin >> T; while (T--) { int flag = 0; cin >> n; for (int i = 0; i < n; i++) cin >> ar[i]; sort(ar, ar + n); flag = ar[1] - ar[0]; for (int i = 1; i < n - 1; i++) { if (flag > ar[i + 1] - ar[i]) { fl...
### Prompt In CPP, your task is to solve the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least on...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int inf = 0x3f3f3f3f; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int m = inf; for (int i = 0; i < n - 1; i++) { m = min(m,...
### Prompt In cpp, your task is to solve the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least on...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n; cin >> n; int ar[n]; for (int i = 0; i < n; i++) cin >> ar[i]; sort(ar, ar + n); int best = 100000; for (int i = 0; i < n - 1; i++) { best = min(best, abs(ar[i] - ar[i + 1])); ...
### Prompt Generate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int s[55]; for (int i = 0; i < n; i++) { cin >> s[i]; } sort(s, s + n, greater<int>()); int min = INT_MAX; for (int i = 0; i < n - 1; i++) { int temp = s[i] - s[i ...
### Prompt Your task is to create a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have ...
#include <bits/stdc++.h> using namespace std; int t; int a[1001]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { int n; int ans = 1e8; cin >> n; memset(a, 0, sizeof(a)); for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i ...
### Prompt Generate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int arvore[100006]; int n; long long binpow(long long a, long long b) { long long res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res; } int soma(int x) { int s = 0; while (x > 0) { s += arvore[x]; x -= (x & -x...
### Prompt Your challenge is to write a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int k = 0; k < n; k++) { int s, m = 1000; cin >> s; int a[s]; for (int i = 0; i < s; i++) { cin >> a[i]; } sort(a, a + s); for (int i = 0; i < s - 1; i++) { m = min(m, (a[i + 1] - a[i])); }...
### Prompt Your challenge is to write a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << '\n'; err(++it, args...); } long long powMod(long long x, long long y) { long long p = 1; while (...
### Prompt Please create a solution in cpp to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, i, min, b; scanf("%d", &t); while (t) { scanf("%d", &n); int a[n]; for (i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); min = 1001; for (i = 0; i < n - 1; i++) { b = a[i + 1] - a[i]; if (b < min) min = ...
### Prompt Generate a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int m = a[1] - a[0]; for (int i = n - 1; i >= 2; i--) { int k = a[i] - a[i - 1]; if (k...
### Prompt Develop a solution in cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; void FAST() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int Rselect(vector<int>&, int, int, int); int partition(vector<int>&, int, int); template <typename T> ostream& operator<<(ostream& stream, const vector<T>& vec) { for (auto& i : vec) { stream << ...
### Prompt Develop a solution in cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; template <typename T> T fact(T n) { return (n == 1 || n == 0) ? 1 : n * fact(n - 1); } bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } int power(int x, unsigned int y) { int res = 1; while (y > 0) { if (y & 1) r...
### Prompt Please create a solution in cpp to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; void solve() { long long n, i; cin >> n; vector<long long> vec(n); for (i = 0; i < n; i++) { cin >> vec[i]; } sort(vec.begin(), vec.end()); long long ans = INT_MAX; for (i = 1; i < n; i++) { ans = min(ans, vec[i] - vec[i - 1]); } cout << ans << '...
### Prompt Generate a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { int t; cin >> t; while (t--) { int ans = 1e9; v.clear(); int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(x); } sort(v.begin(), v.end()); for (int i = 1; i < v.siz...
### Prompt Create a solution in cpp for the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one...
#include <bits/stdc++.h> using namespace std; int i, j, count1 = 0, count2 = 0; void A(void); void B(void); void C(void); void D(void); void E(void); void F(void); int main(void) { B(); } void B() { int l, t, n, minv, d; cin >> t; for (l = 0; l < t; l++) { cin >> n; vector<int> vec(n); for (i = 0; i <...
### Prompt In Cpp, your task is to solve the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least on...
#include <bits/stdc++.h> using namespace std; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } bool isPrime(long long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long i = 5; i * i <= n; i += 6) { if (n % i == 0 ||...
### Prompt Create a solution in CPP for the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n], i, j; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int min = abs(a[0] - a[1]), x; for (i = 0; i < n - 1; i++) { x = abs(a[i] - a[i + 1]); ...
### Prompt Develop a solution in Cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a; for (b = 0; b <= a - 1; b++) { int n, i, j, x, min; min = 1000; cin >> n; int s[n]; for (i = 0; i <= n - 1; i++) { cin >> s[i]; } for (i = 0; i <= n - 1; i++) { for (j = i + 1; j < n; j++) { ...
### Prompt Please provide a cpp coded solution to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int mini = INT_MAX; int k = 0; for (int i = 0; i < n ...
### Prompt Create a solution in Cpp for the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n], counter = 1000; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); for (int i = 1; i < n; i++) counter = min(counter, abs(arr[i] - arr[i - 1])); cout...
### Prompt Develop a solution in cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, a[50], aux = 0; cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (a[j] > a[j + 1]) { aux = a[j...
### Prompt Your challenge is to write a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int main() { long t, n; cin >> t; while (t--) { cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int ans = a[1] - a[0]; for (int i = 2; i < n; i++) if (a[i] - a[i - 1] < ans) ans = a[i] - a[i - 1]; cout << ...
### Prompt Please formulate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int min(int a, int b) { if (a <= b) { return a; } return b; } int max(int a, int b) { if (a <= b) { return b; } return a; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t) { int n, i; ...
### Prompt Your task is to create a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have ...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int arr[n]; for (long long int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); long long int a = 1e9; for (long long int i = 0; i...
### Prompt Please create a solution in cpp to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int ara[n]; for (int i = 0; i < n; i++) { cin >> ara[i]; } int min = ara[0], c; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (ara[j] ...
### Prompt Develop a solution in cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int n; int col[5005]; vector<int> adj[5005]; bool vis[5005]; void solve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); int mn = 1000000000; for (int i = 1; i < n; i++) { mn = min(mn, a[i] - a[i - 1...
### Prompt Generate a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n, x; cin >> n; vector<long long int> a; a.clear(); for (int i = 0; i < n; i++) { cin >> x; a.push_back(x); } sort(a.begin(), a.end()); long long int mx = 1...
### Prompt Please create a solution in cpp to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int tests; cin >> tests; for (int test = 0; test < tests; ++test) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); int minn = 2000; for (int i = 0; i < n - 1;...
### Prompt Your task is to create a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; std::vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } int min = 100000; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (abs(v...
### Prompt Please formulate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int test; cin >> test; for (int tt = 0; tt < test; tt++) { int n; cin >> n; vector<int> a(n); for (int &x : a) { cin >> x; } sort(a.begin(), a.end()); int result = a[n - 1] - a[0]; for (int i = 0; i < n - 1; i++) { ...
### Prompt Your challenge is to write a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int main() { int tc, n; int minDiff; cin >> tc; while (tc--) { cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); minDiff = 100000; for (int i = 0; i < n - 1; i++) minDiff = min(minDiff, abs(arr[i] - ar...
### Prompt In CPP, your task is to solve the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least on...
#include <bits/stdc++.h> using namespace std; int main() { int t, test; scanf("%d", &test); for (t = 0; t < test; t++) { int i, j, n, m, result, arr[50]; scanf("%d", &n); for (m = 0; m < n; m++) { scanf("%d", &arr[m]); } sort(arr, arr + n); i = INT_MAX; for (m = 0; m < n - 1; m++...
### Prompt Your challenge is to write a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int main() { long long t, i; cin >> t; while (t--) { long long n, m = 100000, k, j; cin >> n; long long a[n + 5]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 1; i < n; i++) { k = a[i] - a[i - 1]; m = min(k, m); ...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int mas[n]; for (int i = 0; i < n; i++) cin >> mas[i]; sort(mas, mas + n); int min = 999999; int a = 0, b = 0; for (int i = 0; i < n - 1; i++) { if (mas[i + 1] - mas[i] < min) { min = mas[i + 1] - mas[i]; a = m...
### Prompt Please create a solution in CPP to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, mini, i; cin >> t; while (t) { mini = INT_MAX; cin >> n; int a[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < n - 1; i++) { mini = min(mini, (a[i + 1] - a[i])); } cout << mini << en...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> #pragma GCC optimize("O0") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("-ffloat-store") using namespace std; long long n, m, a, b, c, k, temp, x, y; const int MAXN = 100000 + 11; inline void read(vector<long lo...
### Prompt Generate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); int n; int i; for (i = 0; i < t; i++) { scanf("%d", &n); int arr[n]; int min = 1005; for (int j = 0; j < n; j++) { scanf("%d", &arr[j]); } sort(arr, arr + n); for (int k = 0; k < n - 1; k++) { ...
### Prompt Please formulate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main(void) { int t, n; cin >> t; while (t--) { cin >> n; vector<int> v(n); map<int, int> mp; bool flag = false; for (auto &x : v) { cin >> x; mp[x]++; if (mp[x] >= 2) { flag = true; } } if (flag) { ...
### Prompt Generate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> s(n); for (int i = 0; i < n; i++) cin >> s[i]; sort(s.begin(), s.end()); int mi = INT_MAX; f...
### Prompt Your challenge is to write a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int n; int a[55]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int result = INT_MAX; for (int i = 0; i < n - 1; i++...
### Prompt In Cpp, your task is to solve the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least on...
#include <bits/stdc++.h> using namespace std; void getans() { int x = INT_MAX, n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; sort(v.begin(), v.end()); for (int i = 1; i < n; i++) { x = min(v[i] - v[i - 1], x); } cout << x << endl; } int main() { std::ios::sync_with_stdio(...
### Prompt Create a solution in CPP for the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, dif = 1001; cin >> n; vector<int> s(n); for (int i = 0; i < n; i++) cin >> s[i]; sort(s.begin(), s.end()); for (int i = 0; i < n - 1; i++) dif = min(dif, s[i + 1] - s[i]); cout << dif << en...
### Prompt Develop a solution in cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); vector<int> nums(n); for (auto &x : nums) { scanf("%d", &x); } sort(nums.begin(), nums.end()); int result = 0x3f3f3f3f; for (int i = 1; i < n; i++) { ...
### Prompt Please create a solution in Cpp to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int x[53]; int main(int argc, char** argv) { int t, n, min; cin >> t; for (int i = 0; i < t; i++) { cin >> n; for (int j = 0; j < n; j++) { cin >> x[j]; } sort(x, x + n); min = x[1] - x[0]; for (int j = 0; j < n - 1; j++) { if (x[j ...
### Prompt In CPP, your task is to solve the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least on...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long n; cin >> n; long long arr[n]; for (long long i = 0; i < n; ++i) { cin >> arr[i]; } sort(arr, arr + n); long ...
### Prompt Create a solution in CPP for the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int t; cin >> t; while (t--) { int n, flag = 0; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); int min = arr[1] - arr[...
### Prompt Construct a Cpp code solution to the problem outlined: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least ...
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int MAX = 1e6; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, ans = INT_MAX; cin >> n; int arr[n + 5]; for (int i = 0; i < n; i++) cin >> arr[i]; sort(a...
### Prompt Please formulate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; void test() { int mi = INT_MAX; int s; cin >> s; vector<int> v(s); while (s) cin >> v.at(v.size() - s--); sort(v.begin(), v.end()); for (int i = 0; i < v.size() - 1; ++i) { mi = min(abs(v.at(i) - v.at(i + 1)), mi); } cout << mi << endl; } int main() { ...
### Prompt Develop a solution in Cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { int n; cin >> n; set<int> st; int t; for (int i = 0; i < n; i++) { cin >> t; st.insert(t); } if (st.size() < n) cout << 0 << "\n"; else { vector<int> s; for (auto...
### Prompt Please formulate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const int N = 1e5 + 5; const int MOD = 1e9 + 7; int main() { int t; cin >> t; while (t--) { int n; cin >> n; std::vector<int> v(n); for (int i = 0; i < n; ++i) scanf("%d", &v[i]); sort(v.begin(), v....
### Prompt Construct a Cpp code solution to the problem outlined: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least ...
#include <bits/stdc++.h> using namespace std; const unsigned int MOD = 1e9 + 7; vector<bool> prime(1000001, true); void seive(int n) { for (int i = 2; i * i <= n; i++) { if (prime[i] == true) { for (int p = i * i; p <= n; p += i) { prime[p] = false; } } } } void solve() { int N; cin ...
### Prompt Develop a solution in cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; using ll = long long; const long long inf = 1e9; ll n, m, k; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { cin >> n; vector<int> v(n); for (auto &x : v) cin >> x; sort(v.begin(), v.end()); int a...
### Prompt Generate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int a = 0; a < t; a++) { int n; cin >> n; int arr[n]; int diff = INT_MAX; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); for (int x = 1; x < n; x++) { if (arr[x] - arr[x...
### Prompt Please create a solution in cpp to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n]; for (long long i = 0; i < n; ++i) { cin >> a[i]; } long long minDiff = 0; sort(a, a + n)...
### Prompt Develop a solution in Cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n + 1]; for (long long i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); long long diff = INT_MAX; for (long long i = 0; i < n - 1; i++) { diff = min(a...
### Prompt Develop a solution in Cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int no; cin >> no; while (no--) { int size; cin >> size; int arr[size]; int i = 0; while (i < size) { cin >> arr[i++]; } sort(arr, arr + size); int least = arr[size - 1] - arr[size - 2], temp; for (i = 0; i < size...
### Prompt Please formulate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> t; for (int i = 0; i < t; i++) { cin >> n; int a[50]; for (int i = 0; i < n; i++) cin >> a[i]; int res = 1000; for (int i = 0; i < n - 1; i++) for (int j = i + 1; j < n; j++) if (abs(a[i] - a[j]) < res) r...
### Prompt Please create a solution in Cpp to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("-O3") const long double PI = 3.141592653589793; bool isPowerOfTwo(int x) { return x && (!(x & (x - 1))); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int t = 0; cin >> t; while (t--) { long long int n, i, p...
### Prompt Please create a solution in CPP to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t, n; cin >> t; while (t--) { cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int lowdif = INT_MAX; for (int i = 1; i < n; i++) { i...
### Prompt Please formulate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, a[100]; cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); vector<int> v; int dif = 0; for (int i = 1; i < n; i++) { dif = a[i] - a[i - 1]; v.push_back(dif...
### Prompt Your challenge is to write a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; bool com(long long a, long long b) { return a < b; } int main() { long long t; cin >> t; while (t--) { long long n, d, ans = 1000; cin >> n; long long a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (long long i = 1; i ...
### Prompt Develop a solution in cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; using ll = long long; using P = pair<ll, ll>; template <class T> using V = vector<T>; const ll inf = (1e18); const ll mod = 1000000007; ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; } ll LCM(ll c, ll d) { return c / GCD(c, d) * d; } struct __...
### Prompt Your task is to create a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } sort(v.begin(), v.end()); int result = v[n - 1] - v[0]; for (int i = 0; i < n; i++) { for (int j = i...
### Prompt Your challenge is to write a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); long long t; cin >> t; for (long long curT = 0; curT < t; ++curT) { long long n; cin >> n; vector<long long> in(n); for (long long i = 0; i < n; ++i) { cin >> in[i]; } sort...
### Prompt Generate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; ++i) cin >> arr[i]; sort(arr, arr + n); int mini = INT_MAX, diff = 0; for...
### Prompt In CPP, your task is to solve the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least on...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, i, j, x, y, ans, k; int ar[100]; scanf("%d", &t); while (t--) { scanf("%d", &n); ans = 99999999; for (i = 1; i <= n; i++) { scanf("%d", &ar[i]); } sort(ar + 1, ar + n + 1); for (i = 1; i < n; i++) { ans = mi...
### Prompt Construct a Cpp code solution to the problem outlined: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least ...
#include <bits/stdc++.h> using namespace std; int tc, n, a[1000]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ; cin >> tc; while (tc--) { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int ans = 1e7; for (int i = 0; i < n; i++) { int t = 0; f...
### Prompt Construct a cpp code solution to the problem outlined: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least ...
#include <bits/stdc++.h> using namespace std; long long t, n, a[100]; int main() { cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; sort(a, a + n); long long ans = 1e9; for (int i = 1; i < n; ++i) { ans = min(a[i] - a[i - 1], ans); } cout << ans << endl; ...
### Prompt Please provide a cpp coded solution to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> athletes(n); for (auto &athlete : athletes) cin >> athlete; sort(athletes.begin(), athletes.end()); int diff = INT_MAX; for (int i = 1; i < n; ++i) { diff = min(diff, athletes[i] - athletes[i - 1]); } cout <<...
### Prompt Please provide a CPP coded solution to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); vector<int> nums(n); for (int i = 0; i < n; i++) { scanf("%d", &nums[i]); } sort(nums.begin(), nums.end()); int result = 0x3f3f3f3f; for (int i = 1; i < n;...
### Prompt Construct a cpp code solution to the problem outlined: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> strength(n, 0); for (int i = 0; i < n; i++) { cin >> strength[i]; } sort(strength.begin(), strength.end()); int mindeff = 10001; for (int i = 0; i < n - 1; i...
### Prompt Develop a solution in Cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); int ans = INT_MAX; for (int i = 1; i < n; i++) { ans = min(ans, a[i] - a[i - 1]); ...
### Prompt Your challenge is to write a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int main() { long long int tc; scanf("%lld", &tc); while (tc--) { long long int n; scanf("%lld", &n); vector<long long int> v; for (long long int i = 0; i < n; i++) { long long int a; scanf("%lld", &a); v.push_back(a); } sort(...
### Prompt Please provide a CPP coded solution to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; int arr[n]; for (int j = 0; j < n; j++) { cin >> arr[j]; } sort(arr, arr + n); int minn = 1000; for (int j = 0; j < n - 1; j++) { if (minn > (arr[j...
### Prompt Construct a Cpp code solution to the problem outlined: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, d = 1001; cin >> n; int s[n]; for (int i = 0; i < n; i++) { cin >> s[i]; } sort(s, s + n); int result = s[n - 1] - s[0]; for (int i = 0; i < n; i++) { for (int j = i + 1; j ...
### Prompt Construct a CPP code solution to the problem outlined: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least ...
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; int arr[n]; map<int, int> maps; for (int i = 0; i < n; i++) { cin >> arr[i]; maps[arr[i]]++; } int flag = 0; for (auto i : maps) { if (i.second > 1) { cout <...
### Prompt Please provide a CPP coded solution to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; int i = 0, j = 0; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } bool isPowerOfTwo(long long n) { return n && (!(n & (n - 1))); } bool is_numeric(char c) { return c >= 'a' and c <= 'z'; } string decToBinary(int n) { string bina...
### Prompt Please provide a CPP coded solution to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> int main() { int t; scanf("%d", &t); int n; for (int i = 0; i < t; i++) { scanf("%d", &n); int a[n]; for (int j = 0; j < n; j++) { scanf("%d", &a[j]); } int min = 10000; for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { int temp; ...
### Prompt Please formulate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int mn = 1001; int vl1 = 0; int vl2 = 0; for ...
### Prompt Create a solution in CPP for the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int powerMod(int x, unsigned int y, int MOD) { int res = 1; x = x % MOD; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD; } return res; } int main() { int t; cin >> t;...
### Prompt Please formulate a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; void input(int &x) { bool neg = false; register int c; x = 0; c = getchar(); if (c == '-') { neg = true; c = getchar(); } for (; (c > 47 && c < 58); c = getchar()) x = (x << 1) + (x << 3) + c - 48; if (neg) x *= -1; } int main() { ios_base::sync_wi...
### Prompt Your challenge is to write a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must h...
#include <bits/stdc++.h> using namespace std; const int MAX = 50; void Get_Array(int n, int a[]) { for (int i = 0; i < n; i++) { cin >> a[i]; } } void Print_Array(int n, int a[]) { for (int i = 0; i < n; i++) { cout << i << "---->" << a[i] << endl; } } void MG(int k, int m, int v[], int u[], int s[]) { ...
### Prompt Construct a CPP code solution to the problem outlined: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int long long n, a[60], mx = 2000; scanf("%lld", &n); for (int i = 0; i < n; i++) { scanf("%lld", &a[i]); } sort(a, a + n); for (int i = 1; i < n; i++) { mx = min(mx, abs(a[i - 1] - a[i]))...
### Prompt Generate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; long long ar[n], ans = 1000000, a, b; for (int i = 0; i < n; i++) { cin >> ar[i]; } sort(ar, ar + n); for (int i = 0; i < n - 1; i++) { a = ar[i + 1] - ar[i]; an...
### Prompt Create a solution in cpp for the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one...
#include <bits/stdc++.h> using namespace std; long long n, a[51]; bool cmp(long long x, long long y) { return x < y; } void A() { long long ans = 1000000000; scanf("%lld", &n); for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]); sort(a + 1, a + n + 1, cmp); for (long long i = 1; i < n; i++) ans = min(ans...
### Prompt Generate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int T; int answer = 0; vector<int> v; int main(void) { ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); cin >> T; while (T--) { v.clear(); int n; cin >> n; v.resize(n); for (int i = 0; i < n; ++i) { cin >> v[i]; } sor...
### Prompt Generate a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int honest_coach(vector<int> arr, int n) { sort(arr.begin(), arr.end()); int result = INT_MAX; for (int i = 0; i < arr.size() - 1; i++) { result = min(result, abs(arr[i] - arr[i + 1])); } return result; } int main() { int T; cin >> T; while (T--) { i...
### Prompt Please create a solution in Cpp to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; vector<long long> p; int ho, mi, se, ho1, mi1, cnt; void fix_time() { if (se > 59) mi += se / 60, se = se % 60; if (se < 0) se += 60, mi--; if (mi > 59) ho += mi / 60, mi = mi % 60; if (mi < 0) mi += 60, ho--; if (ho < 0) ho += 24; if ...
### Prompt Generate a CPP solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; struct compare { bool operator()(pair<long long int, long long int> a, pair<long long int, long long int> b) { if ((a.second - a.first) > (b.second - b.first)) return false; else if ((a.second - a.first) == (b.second - b.first)) { if ...
### Prompt Your task is to create a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have ...
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n; while (n--) { cin >> a; vector<int> vect; int mini(1001); while (a--) { cin >> b; vect.push_back(b); } sort(vect.begin(), vect.end()); for (int i(0); i < vect.size() - 1; i++) { if (abs(...
### Prompt Generate a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int n, m; int read() { int s = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0'; ch = getchar(); } return s * f; } int s[101010]; int m...
### Prompt Develop a solution in CPP to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...
#include <bits/stdc++.h> using namespace std; int abs(int a, int b) { if (a < b) { return b - a; } else { return a - b; } } int main() { int t; int arr[100]; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; for (int j = 0; j < n; j++) { cin >> arr[j]; } int min_va...
### Prompt Your task is to create a cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have ...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; long long t, n, a[55], b; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; long long ans = 1e9; sort(a + 1, a + 1 + n); for (in...
### Prompt Generate a Cpp solution to the following problem: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one a...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int m = a[1] - a[0]; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { ...
### Prompt Develop a solution in Cpp to the problem described below: There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at lea...