# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
256851 | Goolakh | Gap (APIO16_gap) | C++17 | 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.
// FUCKED UP FUCKED UP FUCKED UP FUCKED UP FUCKED UP
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll maxn=1e5+10, maxm=5e4+10, lg=21, mod=998244353, inf=1e18;
const ll MN=0,MX=inf;
ll ret=MN,a[maxn];
ll findGap(ll T,ll n){
if(T==1){
ll L=MN,R=MX,k=0;
for(int i=n;i>0;i-=2){
MinMax(L,R,&a[k],&a[n-1-k]);
L=a[k]+1, R=a[n-1-k]-1;
k++;
}
for(int i=1;i<n;i++) ret=max(ret,a[i]-a[i-1]);
}
else{
ll lf,ri,gap;
MinMax(MN,MX,&lf,&ri);
gap=ret=(ri-lf+n-2)/(n- 1);
ll pr=-1;
for(ll i=lf;i<=ri;i+=gap+1){
ll t1,t2;
MinMax(i,min(i+gap,ri),&t1,&t2);
if(t1!=-1){
if(pr!=-1) ret=max(ret,t1-pr);
pr=t2;
}
}
}
return ret;
}
/*
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
return 0;
}
*/