#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool chmax(ll &a, const ll &b) {
return a < b ? a = b, true : false;
}
long long findGap(int T, int n) {
ll L, R;
MinMax(0, 1e18, &L, &R);
ll len = R - L + 1;
ll lmn = -1, lmx = -1;
ll B = (len + n - 1) / n;
ll ans = B;
for(int i = 0; i < len / B; i++) {
ll cl = i * B + L, cr = min(L + (i + 1) * B - 1, R);
ll mn, mx;
MinMax(cl, cr, &mn, &mx);
// cout << cl << ' ' << cr << ' ' << mn << ' ' << mx << '\n';
if(lmn != -1 && mn != -1) {
chmax(ans, mn - lmx);
}
if(mn != -1) {
lmn = mn, lmx = mx;
}
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |