#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
int n, q;
vector<int> distribute_candies(vi c, vi l, vi r, vi v) {
n = (int)c.size();
q = (int)l.size();
vector<ll> ans(n);
for(int i = 0; i < q; ++i) {
ans[l[i]] += v[i];
if(r[i] + 1 < n) ans[r[i] + 1] -= v[i];
}
for(int i = 1; i < n; ++i) {
ans[i] += ans[i - 1];
}
vi ans2(n);
for(int i = 0; i < n; ++i) {
ans2[i] = min(ans[i], (ll)c[i]);
}
return ans2;
}
//int main() {
//ios_base::sync_with_stdio(0);
//cin.tie(0);
//vector<ll> w = distribute_candies({10, 15, 13}, {0, 0}, {2, 1}, {20, -11});
//vector<ll>w = distribute_candies({10, 15, 13}, {0, 0}, {2, 1}, {8, 4});
//for(int x : w) {
//cout << x << " ";
//}
//}
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
130 ms |
8812 KB |
Output is correct |
2 |
Correct |
126 ms |
8800 KB |
Output is correct |
3 |
Correct |
128 ms |
8900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
292 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 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |