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<algorithm>
#include"ricehub.h"
using namespace std;
long long Sum[100005];
long long getCost(int st, int dr, int X[])
{
    int poz=(st+dr)/2;
    long long rez=-1LL*Sum[poz]+Sum[dr]-Sum[poz];;
    if(st>0)
        rez+=Sum[st-1];
    if((dr-st+1)%2==1)
        rez+=X[poz];
    return rez;
}
int besthub(int N, int L, int X[], long long B)
{
    Sum[0]=X[0];
    for(int i=1; i<=N; i++)
        Sum[i]=Sum[i-1]+X[i];
    int st=0;
    int rez=0;
    for(int i=0; i<N; i++)
    {
        if(getCost(st,i,X)>B)
            st++;
        rez=max(rez,i-st+1);
    }
    return rez;
}
| # | 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... |