#include "candies.h"
#include <limits.h>
#include <algorithm>
#include <vector>
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size();
int q = l.size();
vector<int> s(n);
vector<long long> lls(n);
// queries
for (int j = 0; j < q; ++j) {
int left = l[j];
int right = r[j];
lls[left] += v[j];
if (right < n - 1) {
lls[right + 1] -= v[j];
}
}
// prefix sum
for (int i = 1; i < n; ++i) {
lls[i] += lls[i - 1];
}
// capacity
for (int i = 0; i < n; ++i) {
s[i] = min(lls[i], (long long) c[i]);
}
return s;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
128 ms |
8796 KB |
Output is correct |
2 |
Correct |
115 ms |
12876 KB |
Output is correct |
3 |
Correct |
112 ms |
12748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |