ll@n,@h,@a[n],@b[n]; ll c=0,d=0,e=0,z=0,f=0; rep(i,n){ e+=a[i]; c+=b[i]; d+=(i-f+1)*b[i]; while(d>h){ d-=c; c-=b[f]; e-=a[f]; ++f; } z>?=e; } wt(z);