#abc308f. [abc308_f]Vouchers
[abc308_f]Vouchers
Problem Statement
You are in a store to buy items. The regular price of the -th item is yen (the currency in Japan).
You have coupons. You can use the -th coupon to buy an item whose regular price is at least yen at a -yen discount.
Here, each coupon can be used only once. Besides, multiple coupons cannot be used for the same item.
If no coupon is used for an item, you will buy it for a regular price. Find the minimum possible total amount of money required to buy all the items.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
3 3
4 3 1
4 4 2
2 3 1
Sample Output 1
4
Consider using the -nd coupon for the -st item, and the -rd coupon for the -nd item.
Then, you buy the -st item for yen, -nd item for yen, and -rd item for yen. Thus, you can buy all the items for yen.
Sample Input 2
10 5
9 7 1 5 2 2 5 5 7 6
7 2 7 8 2
3 2 4 1 2
Sample Output 2
37