Submission #1077137

#TimeUsernameProblemLanguageResultExecution timeMemory
1077137juicyRice Hub (IOI11_ricehub)C++17
0 / 100
3 ms856 KiB
#include "ricehub.h" #include <bits/stdc++.h> int besthub(int n, int L, int x[], long long b) { std::vector<long long> a(n), pf(n); for (int i = 0; i < n; ++i) { a[i] = (i ? a[i - 1] : 0) + x[i]; pf[i] = (i ? pf[i - 1] : 0) + a[i]; } auto qry = [&](int l, int r) { int md = (l + r) / 2; return (md - l + 1) * a[md] - pf[md] + (l ? pf[l - 1] : 0LL) + pf[r] - pf[md] - (r - md) * a[md + 1]; }; int res = 0; for (int i = 0, j = 0; i < n; ++i) { while (qry(j, i) > b) { ++j; } res = std::max(res, i - j + 1); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...