Submission #1077140

#TimeUsernameProblemLanguageResultExecution timeMemory
1077140juicyRice Hub (IOI11_ricehub)C++17
100 / 100
17 ms4444 KiB
#include "ricehub.h" #include <bits/stdc++.h> int besthub(int n, int L, int *a, long long b) { std::vector<long long> pf(n); for (int i = 0; i < n; ++i) { pf[i] = (i ? pf[i - 1] : 0LL) + 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]; }; 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...