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;
using ll = long long;
const ll inf = 1e18;
ll a[100100];
int n;
ll ans = 1;
ll findGap(int T, int N) {
n = N;
if (T == 1 || N <= 20) {
a[0] = -1, a[n + 1] = inf + 1;
for (int i = 1;i <= n / 2;i++) {
MinMax(a[i - 1] + 1, a[n - i + 2] - 1, &a[i], &a[n - i + 1]);
}
if (n & 1) {
ll _;
MinMax(a[n / 2] + 1, a[n / 2 + 2] - 1, &a[n / 2 + 1], &_);
}
for (int i = 1;i < n;i++) {
ans = max(ans, a[i + 1] - a[i]);
}
return ans;
}
ll mn, mx;
MinMax(0, inf, &mn, &mx);
ll now = mn;
while (now < mx) {
ll n1, n2;
ll t = ans;
for (;;t *= 2) {
MinMax(now + 1, now + t, &n1, &n2);
if (n1 != -1) break;
}
ans = max(ans, n1 - now);
now = n2;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |