# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
741142 | LCJLY | Rice Hub (IOI11_ricehub) | C++14 | 12 ms | 2264 KiB |
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;
int besthub(int R, int L, int X[], long long B)
{
int n=R,k=L;
long long arr[n+5];
for(int x=0;x<n;x++){
arr[x+1]=X[x];
}
long long psum[n+5];
for(int x=1;x<=n;x++){
psum[x]=psum[x-1]+arr[x];
}
long long l=1;
int ans=0;
for(long long x=1;x<=n;x++){
while(l<x){
long long mid=(l+x)/2;
long long cost=arr[mid]*(mid-l)-(psum[mid-1]-psum[l-1])+(psum[x]-psum[mid])-arr[mid]*(x-mid);
if(cost>B){
l++;
}
else{
break;
}
}
ans=max(ans,(int)x-(int)l+1);
}
return ans;
}
Compilation message (stderr)
# | 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... |