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 "gap.h"
#include <iostream>
using namespace std;
const int nmax=10005;
long long v[nmax];
long long mx,st,dr,act,len,oldlen,inf,sup;
int n,i;
long long findGap(int T, int N)
{
n=N;
if(T==1)
{
mx=0;
v[0]=-1;v[n+1]=1LL*1e18+1;
for(i=1;i<=(n+1)/2;i++)
{
MinMax(v[i-1]+1,v[n-i+2]-1,&v[i],&v[n-i+1]);
}
for(i=1;i<n;i++)
mx=max(mx,v[i+1]-v[i]);
return mx;
}
act=-1;len=1;oldlen=1;
bool bun=1;
MinMax(0,1LL*1e18,&inf,&sup);
act=inf;
for(i=1;i<=n&&bun==1;i++)
{
bool ok=0;
if(act!=-1)oldlen=len;
for(len;act+len<=sup&&ok==0;len*=2)
{
MinMax(act+1,act+len,&st,&dr);
if(st!=-1)
ok=1;
}
if(!ok)
bun=0;
if(act!=-1)
{
len=max(st-act,oldlen);
act=dr;
}
}
return len;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:31:16: warning: statement has no effect [-Wunused-value]
for(len;act+len<=sup&&ok==0;len*=2)
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |