# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
481431 | Mihai_Eduard | Rice Hub (IOI11_ricehub) | 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.
bool verify(int r, int l, int x[], int b, int nr)
{
int st, dr, mij, total;
for(int i=0;i<r-nr+1;i++)
{
st=i;
dr=i+nr-1;
mij=(st+dr)/2;
total=0;
for(int j=st;j<=mij;j++)
total+=x[mij]-x[j];
for(int j=mij+1;j<=dr;j++)
total+=x[j]-x[mij];
if(total<=b)
return true;
}
return false;
}
int besthub(int r, int l, int x[], int b)
{
int st=1, dr=r+1, mij;
while(dr-st>1)
{
mij=(st+dr)/2;
if(verify(r,l,x,b,mij))
st=mij;
else
dr=mij;
}
return st;
}