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"
using namespace std;
#define FOR(i, a, b) for (int i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for (int i = a, _b = b; i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = a; i < _a; ++i)
#define llint long long
#define sz(x) (x.size())
#define LL(x) (x * 2)
#define RR(x) (x * 2 + 1)
#define fi first
#define se second
#define db(x) cout << #x << " = " << x << endl;
#define BIT(x, i) ((x >> i) & 1)
#define MASK(i) (1ll << i)
#define times clock() * 1.0 / CLOCKS_PER_SEC
void openFile() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
const int maxN = 1e5 + 5;
const int maxM = 1e6 + 5;
const llint INF = 1e18 + 100;
vector<llint> lef, rig;
llint findGap(int T, int N) {
if (T == 1) {
llint l = -1, r = INF;
llint nl = 0, nr = 0;
llint res = 0;
FOR(i, 1, (N + 1) / 2) {
MinMax(l + 1, r - 1, &nl, &nr);
lef.push_back(nl);
rig.push_back(nr);
l = nl; r = nr;
}
FOR(i, 1, lef.size() - 1) {
res = max(res, lef[i] - lef[i - 1]);
}
FOR(i, 1, rig.size() - 1) {
res = max(res, rig[i - 1] - rig[i]);
}
res = max(res, rig.back() - lef.back());
return res;
}
else {
llint l, r;
MinMax(-1, INF, &l, &r);
if (N == 2) {
return r - l;
}
llint lower = (r - l) / (N - 1);
llint nl, nr;
do {
llint x = 0;
nl = nr = -1;
while (nl == -1) {
++x;
MinMax(l + 1, l + lower * x, &nl, &nr);
}
lower = max(lower, nl - l);
l = nr;
} while (l != r);
return lower;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |