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