이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
#ifdef Tr___
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
#endif
}
const int maxN = 1e5 + 5;
const int maxM = 1e6 + 5;
const llint INF = 1e18;
llint findGap(int T, int N) {
if (T == 1) {
llint l = 0, r = INF;
llint nl, nr;
llint res = 0;
FOR(i, 1, (N + 1) / 2) {
MinMax(l + 1, r - 1, &nl, &nr);
if (l != 0) {
res = max(res, max(nl - l, r - nr));
}
else if (N == 2) {
res = nr - nl;
break;
}
l = nl; r = nr;
}
return res;
}
else {
llint l, r;
MinMax(0, INF, &l, &r);
if (N == 2) {
return r - l;
}
llint lower = (r - l) / (N - 1);
llint res = lower;
llint nl, nr;
do {
llint x = 0;
nl = nr = -1;
while (nl == -1) {
++x;
MinMax(l + 1, l + lower * x, &nl, &nr);
}
res = max(res, nl - l);
l = nr;
} while (l != r);
return res;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |