| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1343662 | Newtonabc | Gap (APIO16_gap) | C11 | 0 ms | 0 KiB |
#include "gap.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long findGap(int T, int N)
{
if(T==2){
vector<pair<ll,ll>> v;
long long n=N;
ll mn,mx;
ll tmp=1e18;
MinMax(1LL,tmp,&mn,&mx);
ll l=mn,r=mx;
long long rng=r-l+1;
long long sz=(rng+n-1LL)/n;
for(ll i=l;i<=r+sz-1;i+=sz){
ll lb=i-sz+1;
ll sec=i/sz;
//cout<<lb <<" " <<i <<"\n";
MinMax(lb,i,&mn,&mx);
if(mn!=-1) v.push_back({mn,mx});
}
ll ans=LLONG_MIN;
for(int i=0;i<(int)(v.size())-1;i++){
ans=max(ans,v[i+1].first-v[i].second);
}
return ans;
}
return 0;
}
