This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |