#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
std::vector<signed> distribute_candies(std::vector<signed> c, std::vector<signed> l,
std::vector<signed> r, std::vector<signed> v) {
ll n = c.size();
vector<ll> diff(n + 1);
vector<signed> ans(n);
for(ll i = 0; i < n; ++i) {
diff[i] = v[i] - (i > 0 ? v[i - 1] : 0);
}
ll Q = l.size();
for(ll i = 0; i < Q; ++i) {
diff[l[i]] += v[i];
diff[r[i] + 1] -= v[i];
}
ll sum = 0;
for(ll i = 0; i < n; ++i) {
sum += diff[i];
ans[i] = min(sum, (ll)c[i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
8952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |