#include "candies.h"
#include <vector>
#include <algorithm>
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
std::vector<int> r, std::vector<int> v) {
int i, j;
int n = c.size();
std::vector<int> s(n);
int m = v.size();
for (i = 0; i < m; i++) {
if (v[i] > 0)
for (j = l[i]; j <= r[i]; j++)
s[j] = std::min(c[j], s[j] + v[i]);
else
for (j = l[i]; j <= r[i]; j++)
s[j] = s[j] + v[i] < 0 ? 0 : s[j] + v[i];
}
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
280 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5055 ms |
12196 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 |
222 ms |
7984 KB |
Output is correct |
3 |
Correct |
219 ms |
5964 KB |
Output is correct |
4 |
Execution timed out |
5062 ms |
13344 KB |
Time limit exceeded |
5 |
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 |
548 ms |
7644 KB |
Output is correct |
4 |
Correct |
554 ms |
4000 KB |
Output is correct |
5 |
Execution timed out |
5080 ms |
10828 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 |
280 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Execution timed out |
5055 ms |
12196 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |