#include "candies.h"
#include <bits/stdc++.h>
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<long long>s(n);
for(int i=0; i<q; ++i) {
s[l[i]] += v[i];
if(r[i] < n-1) s[r[i] + 1] -= v[i];
}
for(int i=1; i<n; ++i) s[i] += s[i-1];
for(int i=0; i<n; ++i) {
s[i] = min(s[i], (long long)c[i]);
}
vector<int>cs(n);
for(int i=0; i<n; ++i) cs[i] = s[i];
return cs;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
8816 KB |
Output is correct |
2 |
Correct |
77 ms |
12912 KB |
Output is correct |
3 |
Correct |
79 ms |
12748 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 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |