#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;
// }
void p(vi a) {
for (int i : a) cout << i << ' ';
cout << endl;
}
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];
}
for (int i = 0; i < n; i++) {
res[i] = min(res[i], c[i]);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
98 ms |
8156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 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 |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |