Submission #969919

#TimeUsernameProblemLanguageResultExecution timeMemory
969919uriegRice Hub (IOI11_ricehub)C++17
74 / 100
21 ms4260 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; typedef long long ll; /// for moondance int besthub(int R, int L, int X[], long long B){ vector<ll>x(R), p(R); for(int i=0;i<R;i++){ x[i] = X[i]; p[i] = x[i]; if(i)p[i] += p[i-1]; } int ans = 1; for(int i=0;i<R;i++){ int l = 1, r = R; while(l<r){ int m = (l+r+1)/2; // cout<<m<<endl; int l_ = i-m/2+(1-m%2), r_ = i+m/2; if(l_<0 || r_>=R){ r = m-1; continue; } ll sum = p[r_] - p[i] - (x[i]*(r_-i)); sum += x[i]*(i-l_+1) - (!l_ ? 0 : p[i]-p[l_-1]); // cout<<sum<<endl; if(sum <= B)l = m; else r = m-1; } ans = max(ans, l); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...