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;
long long findGap(int q,int x){
if(q==2){
long long l=0,r=1e18,ans=0;
MinMax(l,r,&l,&r);
if(x==2)return r-l;
long long xd=l,dist=0,lol=(r-l+x-2)/(x-1);
while(xd<=r){
long long c1,c2;
MinMax(xd+1,xd+1+lol,&c1,&c2);
if(c1==-1){
dist+=lol+1;
}else{
ans=max(ans,dist+c1);
ans=max(ans,c2-c1);
dist=0;
xd=c1;
}
}
return ans;
}else{
vector<long long>a;
long long c=0,v=1e18,zz=x;
while(zz&&c<=v){
long long l,r;
MinMax(c,v,&l,&r);
if(l==-1)break;
a.push_back(l);if(l!=r)a.push_back(r);
c=l+1;v=r-1;zz-=2;
}
sort(a.begin(),a.end());
long long ret=0;
for(int i=0;i<(int)a.size()-1;i++)ret=max(ret,a[i+1]-a[i]);
return ret;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |