#P329. 练55.4 沙堡
练55.4 沙堡
Description
John built a castle out of sand. Like all castle walls, this wall has many gun ports, and the sections between two adjacent gun ports are called "battlements." The wall has a total of () battlements, each with a height of ().
Now, John wants to adjust the height of the battlements to a certain order of (). For each unit increase in height, John needs () dollars; for each unit decrease, he needs () dollars. The question is: what is the minimum amount of money John needs to achieve his goal?
Input Format
The first line contains three integers , , and .
The next lines each contain two integers and .
Output Format
A single integer representing the minimum cost.
Sample
3 6 5
3 1
1 2
1 211