There are M items in the store.
James wants to buy the most expensive items as possible.
He has N dinars (can be any currency, really doesn’t matter).
He can buy the same item multiple times.
The user should input two integers, N (how much money he has) & M (how many items are in the store) as well as a space-separated string (prices of items).
The output should be how many dinars he has left after buying as much and as expensive things as he can.
Example:
INPUT: OUTPUT:
1250 10
5
1010 357 725 1125 115
Explanation:
He has 1250 RSD, he buys one item at the price of 1125 RSD, he now has 125RSD left.
He can’t buy the items for 1010, 725, nor 357, so he buys the one at the price of 115 RSD. He now has 10 RSD left.
He can’t buy anything anymore so he exits the store.