#abc246c. C - Coupon
C - Coupon
Score : points
问题描述
商店里有 件商品。对于每一件商品 ,第 件商品的价格是 日元(日本货币单位)。
高桥有 张优惠券。
每张优惠券可以用于一件商品上。你可以对同一件商品使用任意数量的优惠券,甚至可以不使用优惠券。在价格为 日元的商品上使用 张优惠券后,你能够以 日元的价格购买它。
请输出高桥购买所有商品所需的最小金额。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are items in a shop. For each , the price of the -th item is yen (the currency of Japan).
Takahashi has coupons.
Each coupon can be used on one item. You can use any number of coupons, possibly zero, on the same item. Using coupons on an item with a price of yen allows you to buy it for yen.
Print the minimum amount of money Takahashi needs to buy all the items.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
5 4 7
8 3 10 5 13
Sample Output 1
12
By using coupon on the -st item, coupon on the -rd item, and coupons on the -th item, Takahashi can:
- buy the -st item for yen,
- buy the -nd item for yen,
- buy the -rd item for yen,
- buy the -th item for yen,
- buy the -th item for yen,
for a total of yen, which is the minimum possible.
Sample Input 2
5 100 7
8 3 10 5 13
Sample Output 2
0
Sample Input 3
20 815 60
2066 3193 2325 4030 3725 1669 1969 763 1653 159 5311 5341 4671 2374 4513 285 810 742 2981 202
Sample Output 3
112
update @ 2024/3/10 10:33:17