#abc308f. F - Vouchers
F - Vouchers
Score : points
问题描述
你正在一家商店购买 件商品。第 件商品的原价为 日元(日本货币单位)。
你现在拥有 张优惠券。你可以使用第 张优惠券以 日元的折扣购买原价至少为 日元的商品。
需要注意的是,每张优惠券只能使用一次,并且对于同一件商品不能同时使用多张优惠券。
若某件商品未使用任何优惠券,则将以原价购买。请计算购买全部 件商品所需的最低总价。
以上为通义千问 qwen-max 翻译,仅供参考。
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
update @ 2024/3/10 08:44:50