Submission #231918

#TimeUsernameProblemLanguageResultExecution timeMemory
231918IOrtroiiiRice Hub (IOI11_ricehub)C++14
68 / 100
21 ms2560 KiB
#ifndef KienVu #include "ricehub.h" #endif #include <bits/stdc++.h> using namespace std; using ll = long long; int besthub(int R, int L, int X[], ll B) { vector<ll> pref(R + 1); for (int i = 0; i < R; ++i) pref[i + 1] = pref[i] + X[i]; auto cost = [&](int l, int r) { int md = (l + r) >> 1; return ll(md + 1 - l) * X[md] - (pref[md + 1] - pref[l]) - (r - md) * X[md] + (pref[r + 1] - pref[md + 1]); }; int ans = 0; int r = 0; for (int l = 0; l < R; ++l) { while (r + 1 < R && cost(l, r + 1) <= B) r++; ans = max(ans, r - l + 1); } return ans; } #ifdef KienVu int main() { int R, L, B; while (cin >> R >> L >> B) { int X[R]; for (int i = 0; i < R; ++i) cin >> X[i]; cout << besthub(R, L, X, B) << "\n"; } } #endif // KienVu
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...