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>
using namespace std;
#include "gap.h"
long long findGap(int T, int N){
if(T==1){
long long l=1,r=1e18,res=0;
long long mn,mx;
vector<long long>v;
while(l<=r){
MinMax(l,r,&mn,&mx);
v.push_back(mn);
if(mx!=mn)v.push_back(mx);
l=mn+1;
r=mx-1;
}
sort(v.begin(),v.end());
for(int i=1;i<N;i++)res=max(res,v[i]-v[i-1]);
return res;
}else{
long long l=1,r=1e18,res=0,mn,mx,x,y,i;
MinMax(l,r,&mn,&mx);
long long bsz=(mx-mn+N-2)/(N-1);
res=bsz;l=mn;
for(i=mn;i+bsz<mx;i+=bsz+1){
MinMax(i,i+bsz,&x,&y);
if(~x){
res=max(res,x-l);
l=y;
}
}
MinMax(i,mx,&x,&y);
if(~x)res=max(res,x-l);
return res;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |