# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1146068 | Khalid_Alabdullatif | Gap (APIO16_gap) | C++20 | 0 ms | 0 KiB |
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
long long findGap(int T, int n)
{
ll mn,mx;
MinMax(0,1e18,&mn,&mx);
ll l=mn,r=mx;
ll block=(r-l-1)/(n-1)+1;
ll ans=0,last=mn;
for(int i=mn;i<r;i+=block){
MinMax(i+1,i+block,&mn,&mx);
if(mx!=-1)
ans=max({ans,mn-last,mx-mn}),last=mx;
}
return ans;
}