이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define MAXN 100010
using namespace std;
#include "gap.h"
int query(long long a, long long b, long long &x, long long &y){
MinMax(a, b, &x, &y);
return 0;
}
long long res[MAXN];
long long findGap(int T, int n){
long long l = 0, r = 1e18;
query(l, r, res[0], res[n-1]);
long long difmax = res[n-1] - res[0];
long long resp = difmax/n;
long long val = res[0];
while(val <= res[n-1]){
long long x, y;
query(val+1, val+resp, x, y);
if(x == -1){
l = resp+1; r = res[n-1] - val;
while(l < r){
int mid = (l+r)/2;
query(val+1, val+mid, x, y);
if(x == -1){
l = mid+1;
}
else{
r = y-val-1;
}
}
// cout << val << ' ' << l << ' ' << r << '\n';
resp = max(l, r)+1;
query(val+1, val+resp, x, y);
val = y+1;
}
else{
val = y+1;
}
}
return resp;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |