#include "candies.h"
#include <cstdio>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
const int N = 200000;
int n, a[N], c[N];
std::vector<int> distribute_candies(std::vector<int> c_, std::vector<int> l, std::vector<int> r, std::vector<int> v) {
n = (int)c_.size();
for (int i = 0; i < n; ++i) c[i] = c_[i];
for (int i = 0; i < (int)l.size(); ++i) {
int ll = l[i], rr = r[i] + 1, d = v[i];
for (int j = ll; j < rr; ++j) a[j] += d;
if (d > 0) {
for (int j = ll; j < rr; ++j) a[j] = a[j] < c[j] ? a[j] : c[j];
} else {
for (int j = ll; j < rr; ++j) a[j] = a[j] < 0 ? 0 : a[j];
}
}
std::vector<int> ans(n);
for (int i = 0; i < n; ++i) ans[i] = a[i];
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5055 ms |
12964 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
106 ms |
8048 KB |
Output is correct |
3 |
Correct |
96 ms |
7484 KB |
Output is correct |
4 |
Correct |
4970 ms |
14824 KB |
Output is correct |
5 |
Execution timed out |
5045 ms |
14436 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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
146 ms |
7760 KB |
Output is correct |
4 |
Correct |
177 ms |
5552 KB |
Output is correct |
5 |
Execution timed out |
5063 ms |
11596 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
444 KB |
Output is correct |
6 |
Execution timed out |
5055 ms |
12964 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |