Problem C
Cent Savings

When I get to the cash register, I put all my
It is possible to divide my purchase into groups and to pay
for the parts separately. I managed to find
Input
The input consists of:
-
one line with two integers
( ) and ( ), the number of items and the number of available dividers; -
one line with
integers ( for ), the prices of the items in cents. The prices are given in the same order as the items appear on the belt.
Output
Output the minimum amount of money needed to buy all the
items, using up to
Sample Input 1 | Sample Output 1 |
---|---|
5 1 13 21 55 60 42 |
190 |
Sample Input 2 | Sample Output 2 |
---|---|
5 2 1 1 1 1 1 |
0 |