#include <vector>
#include <algorithm>
using namespace std;
vector<int> distribute_candies(vector<int> c,vector<int> l,vector<int> r,vector<int> v) {
int n = c.size(), q = r.size();
vector<int> boxes(n, 0);
for (int i = 0; i < q; i++){
int left = l[i], right = r[i], value = v[i];
if (value > 0){
for (int j = left; j <= right; j++){
boxes[j] = min(c[j], boxes[j] + value);
}
} else {
for (int j = left; j <= right; j++){
boxes[j] = max(0, boxes[j] + value);
}
}
}
return boxes;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |