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 <algorithm>
long long psum[100100];
int besthub(int R, int L, int X[], long long B)
{
int i;
for(i=0;i<R;i++)
{
psum[i+1]=psum[i]+X[i];
}
int s=0;
int ans=0;
for(i=0;i<R;i++)
{
while(1)
{
long long curcos=0;
long long m=(s+i)/2;
curcos+=(m-s+1)*X[m];
curcos-=psum[m+1]-psum[s];
curcos-=(i-m)*X[m];
curcos+=psum[i+1]-psum[m+1];
if(curcos<=B)
break;
s++;
}
ans=std::max(ans,i-s+1);
}
return ans;
}
# | 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... |