# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
378060 | 2021-03-15T22:12:04 Z | MilosMilutinovic | Rice Hub (IOI11_ricehub) | C++14 | 29 ms | 2688 KB |
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int besthub(int n, int len, int* a, long long b) { vector<long long> pref(n); for (int i = 0; i < n; i++) { if (i == 0) { pref[i] = a[i]; } else { pref[i] = pref[i - 1] + a[i]; } } auto Can = [&](int l, int r) { int mid = l + r >> 1; long long ll = (long long) a[mid] * (mid - l + 1) - (pref[mid] - (l == 0 ? 0LL: pref[l - 1])); long long rr = pref[r] - pref[mid] - (long long) a[mid] * (r - mid); return ll + rr <= b; }; int ans = 1; for (int i = 0; i < n; i++) { int bot = i, top = n - 1, mx = 0; while (bot <= top) { int mid = bot + top >> 1; if (Can(i, mid)) { mx = mid - i + 1; bot = mid + 1; } else { top = mid - 1; } } ans = max(ans, mx); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 2 ms | 364 KB | Output is correct |
22 | Correct | 2 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 2 ms | 492 KB | Output is correct |
25 | Correct | 2 ms | 364 KB | Output is correct |
26 | Correct | 2 ms | 364 KB | Output is correct |
27 | Correct | 2 ms | 364 KB | Output is correct |
28 | Correct | 2 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 748 KB | Output is correct |
2 | Correct | 4 ms | 748 KB | Output is correct |
3 | Correct | 23 ms | 2540 KB | Output is correct |
4 | Correct | 22 ms | 2540 KB | Output is correct |
5 | Correct | 14 ms | 1260 KB | Output is correct |
6 | Correct | 10 ms | 1260 KB | Output is correct |
7 | Correct | 20 ms | 2284 KB | Output is correct |
8 | Correct | 26 ms | 2284 KB | Output is correct |
9 | Correct | 11 ms | 1260 KB | Output is correct |
10 | Correct | 11 ms | 1132 KB | Output is correct |
11 | Correct | 22 ms | 2540 KB | Output is correct |
12 | Correct | 29 ms | 2688 KB | Output is correct |
13 | Correct | 13 ms | 1388 KB | Output is correct |
14 | Correct | 11 ms | 1280 KB | Output is correct |
15 | Correct | 17 ms | 2028 KB | Output is correct |
16 | Correct | 16 ms | 2028 KB | Output is correct |
17 | Correct | 19 ms | 2284 KB | Output is correct |
18 | Correct | 20 ms | 2284 KB | Output is correct |
19 | Correct | 26 ms | 2412 KB | Output is correct |
20 | Correct | 25 ms | 2412 KB | Output is correct |