#include "candies.h"
#include <bits/stdc++.h>
typedef std::vector<int> ivec;
#define int long long
ivec distribute_candies(ivec c, ivec l,
ivec r, ivec v) {
int N = c.size();
int Q = l.size();
ivec ans(N);
int diff[N + 1];
for (int i = 0; i <= N; ++i) {
diff[i] = 0;
}
for (int i = 0; i < Q; ++i) {
diff[l[i]] += v[i];
diff[r[i] + 1] -= v[i];
assert(v[i] >= 0);
}
for (int i = 1; i <= N; ++i) {
diff[i] += diff[i - 1];
assert(diff[i] >= 0);
}
assert(diff[N] == 0);
for (int i = 0; i < N; ++i) {
ans[i] = std::min<int>(diff[i], c[i]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
8860 KB |
Output is correct |
2 |
Correct |
79 ms |
12880 KB |
Output is correct |
3 |
Correct |
80 ms |
12836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |