#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 <int> res(n);
for (int i = 0; i < n; ++i) {
res[i] = 0;
}
for (int i = 0; i < q; ++i) {
if (v[i] > 0) {
for (int j = l[i]; j <= r[i]; ++j) {
res[j] = min(c[j], res[j] + v[i]);
}
}
else {
for (int j = l[i]; j <= r[i]; ++j) {
res[j] = max(0, res[j] + v[i]);
}
}
}
return res;
}
# |
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 |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5059 ms |
7256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
172 ms |
8032 KB |
Output is correct |
3 |
Correct |
157 ms |
6012 KB |
Output is correct |
4 |
Execution timed out |
5011 ms |
13216 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
292 KB |
Output is correct |
3 |
Correct |
397 ms |
7652 KB |
Output is correct |
4 |
Correct |
372 ms |
4008 KB |
Output is correct |
5 |
Execution timed out |
5063 ms |
10776 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Execution timed out |
5059 ms |
7256 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |