#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size();
int q = l.size();
vector<vector<int>> ql(n), qr(n);
for (int i = 0; i < q; ++i) {
ql[l[i]].push_back(i);
qr[r[i]].push_back(i);
}
vector<int> s(n);
vector<int> ops(q);
for (int i = 0; i < n; ++i) {
for (int j : ql[i]) {
ops[j] = v[j];
}
int sum = 0;
for (int j = 0; j < q; ++j) {
sum += ops[j];
sum = max(sum, 0);
sum = min(sum, c[i]);
}
s[i] = sum;
for (int j : qr[i]) {
ops[j] = 0;
}
}
return s;
}
# |
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 |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
8 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5032 ms |
24696 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
666 ms |
11732 KB |
Output is correct |
3 |
Correct |
655 ms |
14404 KB |
Output is correct |
4 |
Execution timed out |
5068 ms |
30508 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
657 ms |
10312 KB |
Output is correct |
4 |
Correct |
652 ms |
13328 KB |
Output is correct |
5 |
Execution timed out |
5055 ms |
22812 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
8 ms |
468 KB |
Output is correct |
6 |
Execution timed out |
5032 ms |
24696 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |