# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
708897 | sofija6 | Rice Hub (IOI11_ricehub) | C++14 | 23 ms | 3276 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>
#define ll long long
#define MAXR 100010
using namespace std;
ll pref[MAXR],a[MAXR];
ll Calc(ll L,ll R,ll pos)
{
ll l=L,r=R,mid,p;
while (l<=r)
{
mid=(l+r)/2;
if (a[mid]<=pos)
{
p=mid;
l=mid+1;
}
else
r=mid-1;
}
return pos*(p-L+1)-(pref[p]-pref[L-1])+pref[R]-pref[p]-pos*(R-p);
}
ll Check(ll x,ll n)
{
ll ans=LLONG_MAX;
for (ll i=1;i<=n-x+1;i++)
ans=min(ans,Calc(i,i+x-1,a[(2*i+x)/2]));
return ans;
}
int besthub(int R,int L,int X[],ll B)
{
for (ll i=0;i<R;i++)
{
pref[i+1]=pref[i]+X[i];
a[i+1]=X[i];
}
int l=1,r=R,mid,ans;
while (l<=r)
{
mid=(l+r)/2;
if (Check(mid,R)<=B)
{
ans=mid;
l=mid+1;
}
else
r=mid-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... |