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 "gap.h"
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
ll findGap(int T, int N) {
ll mn, mx;
MinMax (1, 1e18, &mn, &mx);
ld d = (ld) (mx - mn - 2) / N;
ld l = mn + 1, r = mn + 1 + d;
ll gap = 0, mx_old = mn;
for (int i = 0; i < N - 1; i++) {
MinMax(ceil (l), floor (r), &mn, &mx);
if (mn != -1) {
gap = max (gap, mn - mx_old);
mx_old = mx;
}
l += d, r += d;
}
MinMax(ceil (l) + (ceil (l) == mx_old), floor (r), &mn, &mx);
if (mn != -1) {
gap = max (gap, mn - mx_old);
mx_old = mx;
}
gap = max (gap, mx - mx_old);
return gap;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |