이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstdio>
#include <vector>
#include "gap.h"
using namespace std;
typedef long long int lli;
const lli maxn = int(1e5)+5, inf = lli(1e18)+1;
lli ans = 0, A[maxn];
void sub1(lli n)
{
pair<lli, lli> range = {0, inf};
lli L = 0, R = n-1;
while(L <= R)
{
MinMax(range.first, range.second, &A[L], &A[R]);
range.first = A[L]+1, range.second = A[R]-1;
L++, R--;
}
for(lli i = 1;i < n;i++) ans = max(ans, A[i]-A[i-1]);
}
void qry(lli L, lli R)
{
//cout << L << " " << R << "\n";
if(R-L < ans) return;
pair<lli, lli> left = {L, (L+R)/2}, right = {(L+R)/2+1, R};
pair<lli, lli> leftst, rightst;
MinMax(left.first, left.second, &leftst.first, &leftst.second), MinMax(right.first, right.second, &rightst.first, &rightst.second);
ans = max(ans, rightst.first-leftst.second);
if(leftst.first != leftst.second && leftst.first != -1) qry(leftst.first, leftst.second);
if(rightst.first != rightst.second && rightst.first != -1) qry(rightst.first, rightst.second);
}
void sub2(lli n)
{
qry(0, inf);
}
lli findGap(int t, int n)
{
if(t == 1) sub1(n);
else sub2(n);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |