# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1084412 | MMihalev | 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<iostream>
#include<algorithm>
#include "gap.h"
using namespace std;
long long mn,mx;
long long findGap(int T, int N)
{
__int32 l=-1,r=1000000000000000001LL;
__int32 rem=N;
long long ans=0;
while(rem>0LL)
{
MinMax(l+1,r-1,&mn,&mx);
if(rem==2LL)ans=max(ans,mx-mn);
if(l!=-1LL)
{
ans=max(ans,mn-l);
ans=max(ans,r-mx);
}
if(mn!=mx)rem-=2LL;
else rem--;
l=mn;
r=mx;
}
return ans;
}