# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227783 | 2020-04-28T19:13:51 Z | staniewzki | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; using LL = long long; #include "ricehub.h" int besthub(int R, int L, int X[], LL B) { vector<LL> sum(R + 1); for(int i = 0; i < R; i++) sum[i + 1] = sum[i] + X[i]; auto get = [&](int l, int r) { int m = (l + r) / 2; return sum[r + 1] - sum[m] - X[m] * (r + 1 - m) + X[m] * (m - l) - sum[m] + sum[l]; }; for(int i = 0; i < R; i++) REP(i, R) while(p < R && get(i, p) <= B) ans = max(ans, p++ - i + 1); return ans; }