# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
633920 | fadi57 | Gap (APIO16_gap) | C++14 | 0 ms | 0 KiB |
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;
typedef long long ll;
const ll inf =1e18;
const ll mod=998244353;
ll findGap(ll T, ll N){
ll mn=0; ll mx=1e18;
MinMax( 0, mx, &mn, &mx);
ll st=mn;ll en=mx;
ll len=(mx-(mn+1))/(N-1);
ll last=mn;
vector<ll>v;
v.push_back(mn);
for(ll i=mn+1;i<mx;i+=len){
MinMax( i, i+len-1, &mn, &mx);
if(mn!=-1){
v.push_back(mn); v.push_back(mx);
}
}
v.push_back(en);
ll ans=len;
for(int i=1;i<v.size();i++){
ans=max(ans,v[i]-v[i-1]);
}
return ans;
}