#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];
int C = c[0];
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 ? a[j] : C;
} 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 |
300 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4875 ms |
9408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
98 ms |
5456 KB |
Output is correct |
3 |
Correct |
96 ms |
7556 KB |
Output is correct |
4 |
Correct |
4745 ms |
14764 KB |
Output is correct |
5 |
Correct |
4806 ms |
15204 KB |
Output is correct |
6 |
Correct |
4777 ms |
15612 KB |
Output is correct |
7 |
Correct |
4711 ms |
14952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |