Submission #103411

#TimeUsernameProblemLanguageResultExecution timeMemory
103411wxh010910Rice Hub (IOI11_ricehub)C++17
100 / 100
29 ms2560 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int R, int L, int X[], long long B) { vector<long long> pref(R + 1); for (int i = 0; i < R; ++i) { pref[i + 1] = pref[i] + X[i]; } auto check = [&](int len) { for (int l = 0, r = len; r <= R; ++l, ++r) { int m = (l + r) >> 1; if ((long long) (m - l) * X[m] - (pref[m] - pref[l]) + (pref[r] - pref[m]) - (long long) (r - m) * X[m] <= B) { return true; } } return false; }; int l = 0, r = R; while (l < r) { int mid = (l + r + 1) >> 1; if (check(mid)) { l = mid; } else { r = mid - 1; } } 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...