There are
You are going to hold
- The cost of the participant from each mountain
is the maximum height of the mountains between the mountains and , inclusive. In particular, the cost of the participant from the mountain is , the height of the mountain . - The cost of the meeting is the sum of the costs of all participants.
For each meeting, you want to find the minimum possible cost of holding it.
Note that all participants go back to their own mountains after each meeting; so the cost of a meeting is not influenced by the previous meetings.
Implementation Details
You should implement the following function:
std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R)
H
: an array of length , representing the heights of the mountains.L
andR
: arrays of length , representing the range of the participants in the meetings.- This function should return an array
of length . The value of must be the minimum possible cost of holding the meeting . - Note that the values of
and are the lengths of the arrays, and can be obtained as indicated in the implementation notice.
Example
Let
The grader calls minimum_costs({2, 4, 3, 5}, {0, 1}, {2, 3})
.
The meeting
- The cost of the participant from the mountain
is . - The cost of the participant from the mountain
is . - The cost of the participant from the mountain
is . - Therefore the cost of the meeting
is .
It is impossible to hold the meeting
The meeting
- The cost of the participant from the mountain
is . - The cost of the participant from the mountain
is . - The cost of the participant from the mountain
is . - Therefore the cost of the meeting
is .
It is impossible to hold the meeting
Constraints
Subtasks
- (4 points)
, - (15 points)
, - (17 points)
, , - (24 points)
, , - (40 points) No additional constraints
Comments