100 atcoder#ABC141D. [ABC141D] Powerful Discount Tickets
[ABC141D] Powerful Discount Tickets
Score : points
Problem Statement
Takahashi is going to buy items one by one.
The price of the -th item he buys is yen (the currency of Japan).
He has discount tickets, and he can use any number of them when buying an item.
If tickets are used when buying an item priced yen, he can get the item for (rounded down to the nearest integer) yen.
What is the minimum amount of money required 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 minimum amount of money required to buy all the items.
3 3
2 13 8
9
We can buy all the items for yen, as follows:
- Buy the -st item for yen without tickets.
- Buy the -nd item for yen with tickets.
- Buy the -rd item for yen with ticket.
4 4
1 9 3 5
6
1 100000
1000000000
0
We can buy the item priced yen for yen with tickets.
10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
9500000000