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"
//#include "grader.cpp"
using namespace std;
const long long M = (1e6 + 5);
long long ans;
long long a[M];
long long l,r = 1e18;
long long ll,rr;
long long findGap(int T, int N)
{
if (T == 1 ) {
long long o = (N + 1) / 2;
ll = 1,rr = N;
while (o --) {
MinMax(l,r,&a[ll],&a[rr]);
l = a[ll] + 1,r = a[rr] - 1;
ll ++,rr --;
}
for (long long i = 1; i < N; i ++)
ans = max(ans,a[i + 1] - a[i]);
return ans;
}
else {
long long l = 0,r = 0;
MinMax(0,1e18,&l,&r);
if (N == 2)
return (r - l);
long long last = l;
long long sz = (r - l - 1 + N - 2) / (N - 1);
long long s = l + 1,e = 0;
for (long long i = 1; i < N; i ++) {
e = s + sz - 1;
if (s > e)
break;
MinMax(s,e,&l,&r);
if (l != -1) {
ans = max(ans,l - last);
last = r;
}
s = e + 1;
}
return max(ans,(l - last));
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |