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>
using namespace std;
#include "gap.h"
long long findGap(int T, int n) {
long long mn, mx;
MinMax(0, 1e18, &mn, &mx);
long long delta = (mx - mn) / (n - 1) + ((mx - mn) % (n - 1) > 0);
long long s = mn + 1, last = mn;
long long res = delta, lmt = mx - 1;
long long a = 1e18, b = 0, c = mn, d = mx;
while (s <= lmt) {
long long t = min(lmt, s + delta);
MinMax(s, t, &mn, &mx);
if (mn != -1) {
a = min(a, mn); b = max(b, mx);
res = max(res, mn - last);
last = mx;
}
s = t + 1;
}
if (a == 1e18) res = max(res, d - c);
else res = max(res, a - c), res = max(res, d - b);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |