Submission #112523

#TimeUsernameProblemLanguageResultExecution timeMemory
112523nxteruRice Hub (IOI11_ricehub)C++14
100 / 100
19 ms3328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n,x[100005],k,s[100005]; bool check(int m){ ll l=1,r=m; for(ll i=1;i<=n;i++){ while(abs(x[r+1]-x[i])<abs(x[i]-x[l]))l++,r++; if((s[r]-s[i])-(r-i)*x[i]+(i-l+1)*x[i]-(s[i]-s[l-1])<=k)return true; } return false; } int besthub(int R,int L,int*X,ll B){ n=R,k=B; for(int i=1;i<=n;i++)x[i]=X[i-1],s[i]+=s[i-1],s[i]+=x[i]; x[n+1]=2000000000; int l=1,r=n+1; while(r-l>1){ int m=(l+r)/2; if(check(m))l=m; else r=m; } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...