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 "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int qs[111111];
int besthub(int R, int L, int X[], long long B)
{
for(int i=R;i>0;i--) X[i]=X[i-1];
for(int i=1;i<=R;i++)
{
qs[i]=qs[i-1]+X[i];
}
int mx=0,l=1,r=1;
while(l<=R&&r<=R)
{
int mid=(l+r)/2;
ll cost=qs[r]-qs[mid]-((1ll)*X[mid]*(r-mid))+((1ll)*X[mid]*(mid-l))-qs[mid-1]+qs[l-1];
//cout<<r<<' '<<l<<' '<<r-l+1<<' '<<cost<<'\n';
if(cost<=B) mx=max(mx,r-l+1),r++;
else l++;
}
return mx;
}
# | 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... |