이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
ll findGap(int t, int n)
{
if (t == 1)
{
ll ans = 0;
ll a[n];
ll l = 0, r = 1e18, i = 0, j = n - 1;
while (i <= j)
{
MinMax(l, r, &a[i], &a[j]);
l = a[i++] + 1;
r = a[j--] - 1;
}
for (ll i = 0; i + 1 < n; i++)
ans = max(ans, a[i + 1] - a[i]);
return ans;
}
ll mn, mx;
MinMax(0, 1e18, &mn, &mx);
ll l = (mx - mn + n - 1) / n, r = mx - mn;
while (l <= r)
{
ll mid = (l + r) >> 1, cur = mn, x, y;
bool ok = false;
while (cur + mid <= mx)
{
MinMax(cur + 1, cur + mid - 1, &x, &y);
if (x == -1)
{
// mn = cur;
ok = true;
// break;
}
cur = y;
}
if (ok)
l = mid + 1;
else
r = mid - 1;
}
return --l;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |