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;
long long b[100005];
long long findGap(int T,int N)
{
if (T==1)
{
b[0]=-1;
b[N+1]=1e18;
++b[N+1];
for (int i=1;i<=(N+1)/2;++i) {
if (i>N/2)
{
long long x,y;
MinMax(b[i-1]+1,b[N-i+2]-1,&x,&y);
b[i]=x;
}
else MinMax(b[i-1]+1,b[N-i+2]-1,&b[i],&b[N-i+1]);
}
long long kq=0;
for (int i=2;i<=N;++i) kq=max(kq,b[i]-b[i-1]);
return kq;
}
else
{
long long x,y;
MinMax(0,1e18,&x,&y);
long long X=(y-x+N-1)/N;
long long kq=X;
b[0]=x;
for (int i=1;i<=N;++i)
{
if (x+X*(i-1)+1>y) break;
long long h,k;
MinMax(x+X*(i-1)+1,min(y,x+X*i),&h,&k);
if (k==-1) b[i]=b[i-1];else b[i]=k;
kq=max(kq,h-b[i-1]);
}
return kq;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |