Submission #16223

#TimeUsernameProblemLanguageResultExecution timeMemory
16223ggohRice Hub (IOI11_ricehub)C++98
0 / 100
6 ms5644 KiB
#include "ricehub.h"
#include<cstdio>
int besthub(int r,int l,int *U,long long b)
{
    long long R,L,B,X[100002];
    long long ch,s,p,q,h,i;
    R=r;L=l;B=b;
    for(i=0;i<R;i++)X[i]=U[i];
    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+=(X[i]-X[h-1-i]);
        }
        if(s<=B)ch=1;
        for(i=h;i<R&&ch==0;i++)
        {
            s+=(X[i]-X[i-h/2]);
            s-=(X[i-h/2]-X[i-h]);
            if(s<=B)ch=1;
        }
        if(ch)p=h;
        else q=h;
    }
    return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...