# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
848855 | Mr_Ph | Rice Hub (IOI11_ricehub) | C++14 | 12 ms | 4444 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 "grader.cpp"
#include <bits/stdc++.h>
#define ll long long
#define sz size()
using namespace std;
int besthub(int r, int l, int arr[], long long b)
{
int p1=0,p2=0;
vector<ll>prf(r);
prf[0]=arr[0];
for(int i=1;i<r;i++)
prf[i]=prf[i-1]+arr[i];
int ans=0,ans1=0;
while(p1<r)
{
while(p2<r)
{
int idx=(p1+p2)/2;
ll left=(idx==0?0:prf[idx-1]),right=prf[p2]-prf[idx];
if(p1!=0)left-=prf[p1-1];
ll val=arr[idx];
//int test=left;
left=val*(idx-p1)-left;
right-=val*(p2-idx);
if(right+left<=b){
// cout<<p1<<" "<<p2<<" "<<left<<" "<<right<<endl;
ans=max(ans,(p2-p1+1));
p2++;
}
else break;
}
p1++;
}
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... |