# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
709232 | lmqzzz | Gap (APIO16_gap) | C++14 | 0 ms | 0 KiB |
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>
using namespace std;
long long findGap(int T, int N) {
if (T == 1) {
vector<int64_t> l, r;
int times = N + 1 >> 1;
int64_t ll = 0, rr = 1e18;
while (times--) {
int64_t a, b;
MinMax(ll, rr, &a, &b);
l.emplace_back(a);
r.emplace_back(b);
ll = a + 1, rr = b - 1;
assert(ll <= rr);
}
if (l.back() == r.back()) l.pop_back();
reverse(r.begin(), r.end());
l.insert(l.end(), r.begin(), r.end());
int64_t res = 0;
for (int i = 1; i < N; i++) res = max(res, l[i] - l[i - 1]);
return res;
}
return 0;
}