# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
518796 |
2022-01-24T16:24:03 Z |
sliviu |
Rice Hub (IOI11_ricehub) |
C++17 |
|
16 ms |
2128 KB |
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int n, int L, int a[], long long cmax) {
long long curcost = 0;
int sol, cursol = 1;
queue<int> l, r;
l.emplace(0);
for (int i = 1; i < n; ++i)
r.emplace(i);
while (!r.empty() && a[r.front()] - a[0] <= cmax - curcost) {
++cursol, curcost += a[r.front()] - a[0];
r.pop();
}
sol = cursol;
for (int i = 1; i < n; ++i) {
curcost += 1LL * (a[i] - a[i - 1]) * l.size();
curcost -= 1LL * (a[i] - a[i - 1]) * (cursol - l.size());
while (!l.empty() && curcost > cmax) {
curcost -= a[i] - a[l.front()];
--cursol;
l.pop();
}
while (!r.empty() && a[r.front()] - a[i] <= cmax - curcost) {
++cursol;
curcost += a[r.front()] - a[i];
r.pop();
}
while (!r.empty() && a[r.front()] - a[i] - (l.empty() ? 0 : a[i] - a[l.front()]) <= 0) {
cursol += l.empty();
curcost += a[r.front()] - a[i] - (l.empty() ? 0 : a[i] - a[l.front()]);
if (!l.empty())
l.pop();
r.pop();
}
l.emplace(i);
sol = max(sol, cursol);
}
return sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
308 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
0 ms |
300 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
0 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
208 KB |
Output is correct |
21 |
Correct |
1 ms |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
304 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
0 ms |
208 KB |
Output is correct |
26 |
Correct |
0 ms |
208 KB |
Output is correct |
27 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
460 KB |
Output is correct |
2 |
Correct |
2 ms |
572 KB |
Output is correct |
3 |
Correct |
13 ms |
2080 KB |
Output is correct |
4 |
Correct |
13 ms |
2128 KB |
Output is correct |
5 |
Correct |
6 ms |
916 KB |
Output is correct |
6 |
Correct |
6 ms |
976 KB |
Output is correct |
7 |
Correct |
13 ms |
1876 KB |
Output is correct |
8 |
Correct |
11 ms |
1888 KB |
Output is correct |
9 |
Correct |
6 ms |
916 KB |
Output is correct |
10 |
Correct |
9 ms |
980 KB |
Output is correct |
11 |
Correct |
15 ms |
2124 KB |
Output is correct |
12 |
Correct |
12 ms |
2120 KB |
Output is correct |
13 |
Correct |
6 ms |
984 KB |
Output is correct |
14 |
Correct |
7 ms |
1064 KB |
Output is correct |
15 |
Correct |
9 ms |
1604 KB |
Output is correct |
16 |
Correct |
10 ms |
1608 KB |
Output is correct |
17 |
Correct |
13 ms |
1840 KB |
Output is correct |
18 |
Correct |
12 ms |
2020 KB |
Output is correct |
19 |
Correct |
16 ms |
1996 KB |
Output is correct |
20 |
Correct |
13 ms |
1996 KB |
Output is correct |