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;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
const int nax=2e3+5;
void MinMax(long long, long long, long long*, long long*);
long long findGap(int T, int N)
{
if(T==1){
long long lst,mx;
MinMax(0,1e18,&lst,&mx);
if(N==2) return mx-lst;
//else if(N<=N){
long long ans=0;
int j=N-1;
int i=2;
while(i<=j){
long long a,b;
MinMax(lst+1,mx-1,&a,&b);
ans=max(ans,max(a-lst,mx-b));
lst=a;
mx=b;
i++;j--;
}
return max(ans,mx-lst);
}else{
long long lst,mx;
MinMax(0,1e18,&lst,&mx);
if(N<=2) return mx-lst;
long long ans=1;
while(mx!=lst){
long long a,b;
MinMax(lst+1,lst+ans,&a,&b);
if(a==-1){
while(a==-1){
ans*=2;
MinMax(lst+1,lst+ans,&a,&b);
}
ans=a-lst;
lst=b;
}else{
lst=b;
}
}
return ans;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |