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 ll = long long;
long long findGap(int T, int N)
{
if (T == 1) {
ll low = 0;
ll high = (ll)(1e18);
ll arr[N];
int l = 0;
int r = N-1;
while (l <= r) {
MinMax(low, high, &low, &high);
arr[l++] = low;
arr[r--] = high;
low++;
high--;
}
ll mx = 0;
for (int i = 1; i < N; i++) {
mx = std::max(mx, arr[i] - arr[i-1]);
}
return mx;
}
else {
ll first = 0;
ll last = 0;
MinMax(first, (ll)(1e18), &first, &last);
ll d = (last-first + N-2)/(N-1);
ll ans = 0;
ll next = first+d;
first++;
while (first < last) {
ll mn, mx;
MinMax(first, next, &mn, &mx);
if (mn != -1) {
ans = std::max(mn - (first-1), ans);
first = mx+1;
next = mx;
}
next += d;
}
return ans;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |