이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
ll findGap(int T, int N){
if (T==1){
ll L, R, ans = 0;
MinMax(0, (ll)1e18, &L, &R);
int cnt = 1;
while(true){
ll nL, nR;
if (L+1<=R-1 && cnt < (N+1)/2) MinMax(L+1, R-1, &nL, &nR);
else nL = -1;
if (nL==-1) {ans = max(ans, R - L); return ans;}
ans = max(ans, max(nL - L, R - nR));
L = nL, R = nR;
cnt++;
}
}
ll L, R;
MinMax(0, (ll)1e18, &L, &R);
ll len = R - L;
ll Bsz = len / (N-1);
ans = Bsz;
ll prv = -1;
for (ll i=L;i<=R;i+=Bsz+1){
ll tL, tR;
MinMax(i, i+Bsz, &tL, &tR);
if (tL!=-1 && prv!=-1) ans = max(ans, tL - prv);
if (tR!=-1) prv = tR;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |