#include "ricehub.h"
#define MAXN 100005
typedef long long lld;
static int N; lld X[MAXN],S[MAXN];
lld get_sum(int s,int e,int t)
{
return S[e]-S[t]-X[t]*(e-t)+X[t]*(t-s)-(S[t-1]-S[s-1]);
}
int besthub(int n, int L, int x[], lld B)
{
int i,s,e,ans=0;
N = n;
for (i=0;i<N;i++) X[i+1] = x[i];
for (i=1;i<=N;i++) S[i] = S[i-1]+X[i];
for (s=e=1;e<=N;e++){
while (s < e && get_sum(s,e,(s+e)>>1) > B) s++;
if (ans < e-s+1) ans = e-s+1;
}
return ans;
}
I2luY2x1ZGUgInJpY2VodWIuaCIKCiNkZWZpbmUgTUFYTiAxMDAwMDUKdHlwZWRlZiBsb25nIGxvbmcgbGxkOwoKc3RhdGljIGludCBOOyBsbGQgWFtNQVhOXSxTW01BWE5dOwoKbGxkIGdldF9zdW0oaW50IHMsaW50IGUsaW50IHQpCnsKICAgIHJldHVybiBTW2VdLVNbdF0tWFt0XSooZS10KStYW3RdKih0LXMpLShTW3QtMV0tU1tzLTFdKTsKfQoKaW50IGJlc3RodWIoaW50IG4sIGludCBMLCBpbnQgeFtdLCBsbGQgQikKewogICAgaW50IGkscyxlLGFucz0wOwogICAgTiA9IG47CiAgICBmb3IgKGk9MDtpPE47aSsrKSBYW2krMV0gPSB4W2ldOwogICAgZm9yIChpPTE7aTw9TjtpKyspIFNbaV0gPSBTW2ktMV0rWFtpXTsKICAgIGZvciAocz1lPTE7ZTw9TjtlKyspewogICAgICAgIHdoaWxlIChzIDwgZSAmJiBnZXRfc3VtKHMsZSwocytlKT4+MSkgPiBCKSBzKys7CiAgICAgICAgaWYgKGFucyA8IGUtcysxKSBhbnMgPSBlLXMrMTsKICAgIH0KICAgIHJldHVybiBhbnM7Cn0K