# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
518801 |
2022-01-24T17:04:00 Z |
sliviu |
Rice Hub (IOI11_ricehub) |
C++17 |
|
18 ms |
1920 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 (curcost > cmax) {
assert(!l.empty());
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();
}
l.emplace(i);
sol = max(sol, cursol);
}
return sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
304 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 |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 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 |
216 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
216 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
300 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 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 |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
304 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
304 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
540 KB |
Output is correct |
2 |
Correct |
3 ms |
592 KB |
Output is correct |
3 |
Correct |
12 ms |
1872 KB |
Output is correct |
4 |
Correct |
12 ms |
1820 KB |
Output is correct |
5 |
Correct |
6 ms |
1024 KB |
Output is correct |
6 |
Correct |
6 ms |
964 KB |
Output is correct |
7 |
Correct |
17 ms |
1860 KB |
Output is correct |
8 |
Correct |
11 ms |
1920 KB |
Output is correct |
9 |
Correct |
6 ms |
988 KB |
Output is correct |
10 |
Correct |
5 ms |
952 KB |
Output is correct |
11 |
Correct |
18 ms |
1868 KB |
Output is correct |
12 |
Correct |
13 ms |
1732 KB |
Output is correct |
13 |
Incorrect |
6 ms |
1084 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |