# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40767 | Just_Solve_The_Problem | Gap (APIO16_gap) | C++11 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <gap.h>
long long findGap(int t, int n) {
long long left;
long long right;
left = 1;
right = 1e18;
long long mn, mx;
long long vec[n];
int cnt = 0;
int cnn = n - 1;
while (mn != mx) {
MinMax(left, right, &mn, &mx);
vec[cnt++] = mn;
if (mn != mx)
vec[cn--] = mx;
left = mn + 1;
right= mx - 1;
}
long long ans = 0;
for (int i = 1; i < n; i++) {
ans = max(ans, vec[i] - vec[i - 1]);
}
return ans;
}