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>
#include "gap.h"
using namespace std;
#define ll long long
ll findGap(int T, int n){
ll L,P;
MinMax(0,1e18,&L,&P);
ll d=(P-L+n-2)/(n-1);
ll ans=d,x,y;
if (T==1){
for (ll i = 1; i<(n+1)/2; i++){
if (L+1==P)break;
MinMax(L+1,P-1,&x,&y);
if (x==-1){
ans=max(ans,P-L);
break;
}
else ans=max({ans,x-L,P-y});
L=x;
P=y;
}
}
else{
ll iter,l=L;
for (iter = L; iter+d<P; iter+=d+1){
MinMax(iter,iter+d,&x,&y);
if (x!=-1){
ans=max(ans,x-l);
l=y;
}
}
MinMax(iter,P,&x,&y);
if (x!=-1){
ans=max(ans,x-l);
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |