#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
using ll = long long;
ll findGap(int t, int n){
if (t==1){
vector <ll> v;
ll curmn=0,curmx=1e18+1,mn,mx;
for (int i=0; i<(n+1)/2; i++){
MinMax(curmn,curmx,&mn,&mx);
if (mn!=-1){v.push_back(mn);curmn=mn+1;}
if (mx!=-1 && mn!=mx){v.push_back(mx);curmx=mx-1;}
}
sort(v.begin(),v.end());
ll ans=-1;
for (int i=1; i<v.size(); i++){
ans=max(ans,v[i]-v[i-1]);
}
return ans;}
ll mn,mx,ans=0;
MinMax(0,1e18+1,&mn,&mx);
ll mxx = mx;
ll last_large = mn;
ll dis = (mn+mx+n-2)/(n-1);
ll l=mn+1,r=mn+dis;
for (;l<=mxx; l+=dis,r+=dis){
MinMax(l,r,&mn,&mx);
if (l==-1){continue;}
else{
ans=max(ans,mn-last_large);
last_large=mx;
}
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |