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);
ll s = mn, e = 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++) {
ll il = ceil (l - 1e-7) + (ceil (l + 1e-7) == mx_old), ir = floor (r + 1e-7);
//cout << il << ' ' << ir << endl;
MinMax(il, ir, &mn, &mx);
//cout << ' ' << mn << ' ' << mx << endl;
if (mn != -1) {
gap = max (gap, mn - mx_old);
mx_old = mx;
}
l += d, r += d;
}
ll il = ceil (l - 1e-7) + (ceil (l + 1e-7) == mx_old), ir = floor (r + 1e-7);
//cout << il << ' ' << ir << endl;
MinMax(il, ir, &mn, &mx);
//cout << ' ' << mn << ' ' << mx << endl;
if (mn != -1) {
gap = max (gap, mn - mx_old);
mx_old = mx;
}
gap = max (gap, e - mx_old);
return gap;
}
Compilation message (stderr)
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:15:5: warning: unused variable 's' [-Wunused-variable]
15 | ll s = mn, e = mx;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |