#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<pair<int, int>>
#define INF 1000000000
#include <bits/stdc++.h>
using namespace std;
// vi distribute_candies(vi c, vi l, vi r, vi v) {
// int n = c.size();
// int q = l.size();
// vi res(n);
// for (int i = 0; i < q; i++) {
// for (int j = l[i]; j <= r[i]; j++) {
// res[j] += v[i];
// if (res[j] > c[j]) res[j] = c[j];
// if (res[j] < 0) res[j] = 0;
// }
// }
// return res;
// }
vi distribute_candies(vi c, vi l, vi r, vi v) {
int n = c.size();
int q = l.size();
vi diff(n, 0);
for (int i = 0; i < q; i++) {
diff[l[i]] = v[i];
diff[r[i] + 1] = -v[i];
}
vi res(n);
res[0] = diff[0];
for (int i = 1; i < n; i++) {
res[i] = res[i - 1] + diff[i];
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
288 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
12960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
288 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |