#include "candies.h"
#include <vector>
typedef long long ll;
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
std::vector<int> r, std::vector<int> v) {
int n = c.size();
std::vector<int> s;
std::vector<ll> dp(n + 1);
for (int i = 0; i < (int) v.size(); ++i) {
dp[l[i]] += v[i];
dp[r[i] + 1] -= v[i];
}
for (int i = 1; i < (int) n; ++i) dp[i] += dp[i - 1];
for (int i = 0; i < (int) n; ++i) s.push_back(std::min(dp[i], (ll) c[i]));
return s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
9164 KB |
Output is correct |
2 |
Correct |
124 ms |
13244 KB |
Output is correct |
3 |
Correct |
118 ms |
13068 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 |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |