# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076749 | 2024-08-26T16:09:00 Z | TFF | Gap (APIO16_gap) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; long long findGap(int t, int n) { long long mn, mx, left, right; left = 0; right = 1000000000000000000; mn = mx = 0; vector<long long> arr1, arr2; for (int i = 0; i < (n + 1) / 2; i++) { MinMax(left, right, &mn, &mx); arr1.push_back(mn); arr2.push_back(mx); left = mn + 1; right = mx - 1; } long long ans = arr2.back() - arr1.back(); for (int i = 0; i < (int)arr1.size() - 1; i++) { ans = max(ans, arr1[i + 1] - arr1[i]); } for (int i = (int)arr2.size() - 2; i >= 0; i--) { ans = max(ans, arr2[i + 1] - arr2[i]); } return ans; }