# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
785700 | 2023-07-17T13:21:49 Z | Boas | Rice Hub (IOI11_ricehub) | C++17 | 1000 ms | 2844 KB |
#include "ricehub.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; typedef vector<pair<ll, ll>> vii; int besthub(int R, int L, int X[], ll B) { ll prev = X[0]; ll prevInx = 0; vii fields = {{prev, 1}}; for (ll i = 1; i < R; i++) { ll v = X[i]; if (v == prev) { fields[prevInx].second++; } else { fields.push_back({v, 1}); prev = v; prevInx++; } } ll maxRice = 0; for (ll i = 0; i < fields.size(); i++) { const auto &[loc, num] = fields[i]; ll rice = num; ll bLeft = B; ll inxsR = 0; ll inxsL = 0; while (bLeft > 0) { ll diffL = i - inxsL - 1 < 0 ? INT_MAX : loc - fields[i - inxsL - 1].first; ll diffR = i + inxsR + 1 >= fields.size() ? INT_MAX : fields[i + inxsR + 1].first - loc; if (diffL == INT_MAX && diffL == diffR) break; if (diffL <= diffR) { ll fieldCount = fields[i - inxsL - 1].second; inxsL++; ll maxCost = diffL * fieldCount; if (maxCost <= bLeft) { rice += fieldCount; bLeft -= maxCost; } else { ll maxFields = bLeft / (ll)diffL; rice += maxFields; break; } } else { ll fieldCount = fields[i + inxsR + 1].second; inxsR++; ll maxCost = diffR * fieldCount; if (maxCost <= bLeft) { rice += fieldCount; bLeft -= maxCost; } else { ll maxFields = bLeft / (ll)diffR; rice += maxFields; break; } } } if (rice > maxRice) { maxRice = rice; } } return maxRice; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 3 ms | 340 KB | Output is correct |
14 | Correct | 3 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 3 ms | 340 KB | Output is correct |
18 | Correct | 3 ms | 340 KB | Output is correct |
19 | Correct | 5 ms | 340 KB | Output is correct |
20 | Correct | 4 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 49 ms | 340 KB | Output is correct |
24 | Correct | 47 ms | 436 KB | Output is correct |
25 | Correct | 97 ms | 468 KB | Output is correct |
26 | Correct | 94 ms | 468 KB | Output is correct |
27 | Correct | 33 ms | 468 KB | Output is correct |
28 | Correct | 33 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 976 KB | Output is correct |
2 | Correct | 6 ms | 932 KB | Output is correct |
3 | Execution timed out | 1082 ms | 2844 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |