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>
#define nmax 100008
const long long inf = 1e18;
using namespace std;
long long ans = -1, a[nmax];
long long findGap(int T, int n)
{
if (T == 1){
a[0] = -1;
a[n + 1] = inf;
a[n + 1] += 8;
for (int i = 1, j = n; i <= j; i++, j--){
if (i < j)
MinMax(a[i - 1] + 1, a[j + 1] - 1, &a[i], &a[j]);
else
MinMax(a[i - 1] + 1, a[j + 1] - 1, &a[i], &a[n + 2]);
}
for (int i = 1; i < n; i++)
ans = max(ans, a[i + 1] - a[i]);
}
else{
long long u, v, blk, x, y, pre;
MinMax(0, inf + 8, &u, &v);
blk = (v - u) / (n - 1);
pre = u;
for (long long l = u, r = u + blk; l < v; l += blk, r += blk){
if (r >= v)
r = v - 1;
MinMax(l, r - 1, &x, &y);
if (x == -1 && y == -1)
continue;
ans = max(ans, x - pre);
pre = y;
}
ans = max(ans, v - pre);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |