#GD0000005. Thu gom nước tăng lực (Energy Drink Collector)
Thu gom nước tăng lực (Energy Drink Collector)
Energy Drink Collector
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are stores. Store sells at most energy drinks at price each. Buy exactly drinks with minimum total cost.
Input
The first line contains . Each of the next lines contains .
Output
Print the minimum cost.
Subtasks
General constraints:
-
.
-
.
-
.
-
.
-
Subtask 1 (20 points): ,
-
Subtask 2 (30 points): ,
-
Subtask 3 (50 points): No additional constraints.
Examples
Input
2 5
4 9
2 4
Output
12
Explanation
Buy four drinks at price and one at price . The total cost is .