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 "ricehub.h"
#include<cstdio>
int besthub(int R,int L,int *X,long long B)
{
int ch,p,q,h,i;
long long s;
p=0;q=R+1;
while(p!=q-1)
{
h=(p+q)/2;
s=0;
ch=0;
for(i=h/2;i<h;i++)
{
s+=(long long)(X[i]-X[h-1-i]);
}
if(s<=B)ch=1;
for(i=h;i<R&&ch==0;i++)
{
s+=(long long)(X[i]-X[i-h/2]);
s-=(long long)(X[i-h+h/2]-X[i-h]);
if(s<=B)ch=1;
}
if(ch)p=h;
else q=h;
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |