# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
23022 | arman_ferdous | 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.
const long long MAXN = 1e18;
long long findGap(int, int);
void MinMax(long long , long long , long long *, long long *)
long long findGap(int T, int N)
{
long long mmin, mmax;
MinMax(0LL,MAXN,&mmin,&mmax);
long long gap = (mmax-mmin-1)/(N-1), res = -1;
long long L = mmin+1, prevMax = mmin;
while(L+gap<=mmax)
{
long long curMin, curMax;
MinMax(L,L+gap,&curMin,&curMax);
if(curMin != -1 && curMax != -1)
{
long long curDiff = curMin - prevMax;
res = (curDiff > res ? curDiff : res);
prevMax = curMax;
}
L += gap+1;
}
return res;
}