Aunty Khong is preparing
Aunty Khong spends
- If
, Aunty Khong adds candies to box , one by one, until she has added exactly candies or the box becomes full. In other words, if the box had candies before the action, it will have candies after the action. - If
, Aunty Khong removes candies from box , one by one, until she has removed exactly candies or the box becomes empty. In other words, if the box had candies before the action, it will have candies after the action.
Your task is to determine the number of candies in each box after the
Implementation Details
You should implement the following procedure:
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v)
: an array of length . For , denotes the capacity of box . , and : three arrays of length . On day , for , Aunty Khong performs an action specified by integers , and , as described above.- This procedure should return an array of length
. Denote the array by . For , should be the number of candies in box after the days.
Examples
Example 1
Consider the following call:
distribute_candies({10, 15, 13}, {0, 0}, {2, 1}, {20, -11})
This means that box
At the end of day
At the end of day
Day | Box |
Box |
Box |
---|---|---|---|
As such, the procedure should return
Constraints
for all for all for all
Subtasks
- (
points) - (
points) for all - (
points) - (
points) and for all - (
points) No additional constraints.
Sample Grader
The sample grader reads in the input in the following format:
- line
: - line
: - line
: - line
:
The sample grader prints your answers in the following format:
- line
:
Attachment Package
The sample grader and sample test cases are available here: candies.zip.
Comments