이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
ll solve(ll l, ll r)
{
if (l == -1)
return 0;
ll mid = (l + r) >> 1, x, y, x1, y1;
MinMax(l, mid, &x, &y);
MinMax(mid + 1, r, &x1, &y1);
return max({x != -1 ? solve(l, mid) : 0, x1 != -1 ? solve(mid + 1, r) : 0, x1 - y});
}
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;
}
return solve(0, 1e18);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |