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 = 0, hi = 1000000000000000000, prev;
MinMax(lo, hi, &lo, &hi);
ll ans = (hi - lo) / (N - 1);
while (lo <= hi)
{
ll x = -1, y;
ll i = lo, step = ans;
while (x == -1)
{
MinMax(i + 1, i + step, &x, &y);
i += step;
}
ans = max(ans, x - lo);
lo = y;
}
return ans;
}
}
Compilation message (stderr)
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:27:46: warning: unused variable 'prev' [-Wunused-variable]
27 | ll lo = 0, hi = 1000000000000000000, prev;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |