#include <bits/stdc++.h>
using namespace std;
#define int64 long long
const int maxn = 2e5 + 3;
const int64 mod = 1e9 + 7;
vector <int> distribute_candies(vector <int> c, vector <int> l, vector <int> r, vector <int> v) {
int n = c.size(), q = l.size();
vector <int> cd (n);
for (int i = 0; i < q; i++){
cd[l[i]]+=v[i];
if (r[i] + 1 < n)
cd[r[i] + 1]-=v[i];
}
int64 sf = 0;
for (int i = 0; i < n; i++){
sf+=cd[i];
int64 k = min(sf, (int64) c[i]);
cd[i] = k;
}
return cd;
}
// int main() {
// vector <int> p1 = {10, 15, 20};
// vector <int> p2 = {0, 2};
// vector <int> p3 = {2, 2};
// vector <int> p4 = {4, 9};
// for (int i: distribute_candies(p1, p2, p3, p4)) {
// cout << i << " ";
// }
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
7236 KB |
Output is correct |
2 |
Correct |
94 ms |
11432 KB |
Output is correct |
3 |
Correct |
94 ms |
11216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |