# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
775681 | 2023-07-06T18:43:45 Z | kirakaminski968 | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define ll long long using namespace std; int r; ll pref[100005]; int check(int n, int piv, ll lim){ int s,e,m; ll r; for (int i=1; i<=n-piv+1; i++) { s = i; e = i + piv - 1; m = (s+e)/2; r = (pref[e] - sum[m]) - (pref[m-piv%2] - pref[s-1]); if(r <= lim) return 1; } return 0; } int besthub(int R, int L, int* X, ll B){ for (int i=1; i<=R; i++) { pref[i] = pref[i-1] + X[i-1]; } int s = 0, e = R; while (s != e) { int m = (s+e+1)/2; if(check(R,m,B)) s = m; else e = m-1; } return s; }