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 ans,mini,maxi;
long long findGap(int t, int n){
maxi=1e18;
MinMax(0,1e18,&mini,&maxi);
if (t==1){
for (int i=1;i<(n+1)/2;i++){
long long cur1,cur2;
MinMax(mini+1,maxi-1,&cur1,&cur2);
ans=max(ans,cur1-mini);
ans=max(ans,maxi-cur2);
mini=cur1;
maxi=cur2;
}
ans=max(ans,maxi-mini);
}
else {
if (n==2) return maxi-mini;
long long size=maxi-mini+1;
long long l=mini+1,lastguy=mini;
for (int i=1;i<n;i++){
long long cur1,cur2;
long long curr=l+size/(n-1)-1;
if (i<(size)%(n-1)) curr++;
MinMax(l,curr,&cur1,&cur2);
if (cur1!=-1){
ans=max(ans,cur1-lastguy);
lastguy=cur2;
}
l=curr+1;
}
ans=max(ans,l-lastguy);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |