You are the urban designer for a city with
You will be penalized for your inaccuracy in building a wall to hide each of these piles,
Specifically, you will be fined
Each pillar of the wall has an initial height of
Additionally, you can only change the height of a given wall up to
Find the minimum cost for this wall.
Input Specification
The first line will contain
The second line will contain
The third line will contain
Output Specification
Output the minimum cost to be fined for building this wall.
Sample Input
5 1
1 10 3 5 2
1 10 4 3 2
Sample Output
70
Explanation for Sample Output
Note that there are multiple valid solutions yielding the minimum cost.
Here is one valid solution:
Spend the first and only move to set the height for all pillars from
Comments