# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
741138 | LCJLY | Rice Hub (IOI11_ricehub) | C++14 | 12 ms | 1376 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;
int arr[n+5];
for(int x=0;x<n;x++){
arr[x+1]=X[x];
}
int psum[n+5];
for(int x=1;x<=n;x++){
psum[x]=psum[x-1]+arr[x];
}
int l=1;
int ans=0;
for(int x=1;x<=n;x++){
while(l<x){
int mid=(l+x)/2;
int 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,x-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... |