# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
914726 | DucNguyen2007 | Rice Hub (IOI11_ricehub) | C++14 | 2 ms | 2652 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<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxN=1e5+5;
ll sum[maxN+1],a[maxN+1];
ll get(ll l,ll r)
{
return sum[r]-sum[l-1];
}
ll besthub(int L,int n,int x[],ll B)
{
for(int i=0;i<n;i++)
{
a[i+1]=x[i];
}
sum[0]=0;
for(int i=1;i<=n;i++)
{
sum[i]=sum[i-1]+a[i];
}
for(int len=1;len<=n;len++)
{
ll l=1,r=len;
while(r<=n)
{
ll p=(l+r)/2;
ll cur=(p-l+1)*a[p]-get(l,p)+get(p,r)-(r-p+1)*a[p];
if(cur<=B)
{
return len;
}
l++;
r++;
}
}
}
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... |