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"
using namespace std;
typedef long long ll;
ll a[100000];
ll findGap(int T, int N)
{
if (T == 1)
{
ll lo = 0, hi = 1000000000000000000;
int l = 0, r = N - 1;
while (l <= r)
{
MinMax(lo, hi, &a[l], &a[r]);
lo = a[l++] + 1;
hi = a[r--] - 1;
}
ll mx = 0;
for (int i = 0; i < N; i++)
mx = max(mx, a[i+1] - a[i]);
return mx;
}
else
{
ll lo, hi;
MinMax(0, 1e18, &lo, &hi);
ll ans = (hi - lo) / (N - 1), last = lo;
for (ll i = lo; i <= hi; )
{
ll x, y;
MinMax(i + 1, i + ans, &x, &y);
i += ans;
if (x != -1)
{
ans = max(ans, x - last);
last = y;
}
}
return ans;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |