#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pp pair<ll,int>
#define ub(x,i) upper_bound(all(x),i)-x.begin()
using namespace std;
long long cal1(int n){
ll a[n];
ll l=0,r=n-1;
ll mn=0,mx=0;
ll tl=0,tr=1e18;
while(l<=r){
MinMax(tl,tr,a[l],a[r]);
tl=a[l]+1,tr=a[r]-1;
l++,r--;
}ll rs=0;
for(int i=1;i<n;i++)rs=max(rs,a[i]-a[i-1]);
return rs;
}
ll cal2(int n){
ll mn,mx;
ll tl=0,tr=1e18;
MinMax(tl,tr,mn,mx);
ll ans = (mx-mn-1)/(n-1)+1;
ll cl=-1,cr=-1;
ll rl = mn+1,rr=mn+ans;
while(1){
MinMax(rl,rr,cl,cr);
if(cl==-1){
rl = rr+1;
rr = rr+ans;
}
else {
ans = max(ans,cl-mn);
mn=cr;
rl=rr+1;
rr=rr+ans;
if(cr==mx)break;
}
}return ans;
}
long long findGap(int T, int N)
{
if(T==1)return cal1(N);
else return cal2(N);
}
/*int main(){m=5;
b[0]=2;
b[1]=3;
b[2]=6;
b[3]=500;
b[4]=10000;
cout<<findGap(2,5);
}*/
Compilation message
gap.cpp: In function 'long long int cal1(int)':
gap.cpp:21:9: error: 'MinMax' was not declared in this scope
21 | MinMax(tl,tr,a[l],a[r]);
| ^~~~~~
gap.cpp:18:8: warning: unused variable 'mn' [-Wunused-variable]
18 | ll mn=0,mx=0;
| ^~
gap.cpp:18:13: warning: unused variable 'mx' [-Wunused-variable]
18 | ll mn=0,mx=0;
| ^~
gap.cpp: In function 'long long int cal2(int)':
gap.cpp:31:5: error: 'MinMax' was not declared in this scope
31 | MinMax(tl,tr,mn,mx);
| ^~~~~~