410176: GYM103968 B Sour Skittles
Description
You've finished your dinner and want to reward yourself with some Skittles. However, you don't like the regular Skittles at all. Thus, you open your cabinet and see the green wrapper for Sour Skittles. You lay out all the Skittles on the table and measure how much "sour-ness" is in each one, indicated by some value $$$b_i$$$. You want each Skittle you consume to reach a certain threshold ($$$t$$$) of "sour-ness". However, once a Skittle reaches this threshold, they start to get very sour, so you want the sour-ness to be as low as possible (while still reaching the threshold). You will keep consuming Skittles until you either run out or consume $$$k$$$ Skittles. Output the sum of the sourness of all the Skittles that you consume.
InputThe first line will have one integer $$$t$$$ $$$(1 \leq t \leq 50)$$$, representing the threshold of sour-ness you want each Skittle you consume to reach.
The second line will have one integer $$$k$$$ $$$(1 \leq k \leq 50)$$$, representing the number of Skittles you want to consume.
The third line will contain $$$n$$$ integers $$$b_1,...,b_n$$$ $$$(1 \leq n \leq 50, 0 \leq b_i \leq 50)$$$, where $$$b_i$$$ represents the "sour-ness" of the $$$i$$$th Skittle in the bag, and there are $$$n$$$ Skittles total.
OutputOutput a single integer, the sum of the sourness of all Skittles that you choose to consume.
ExamplesInput6 5 1 5 3 2 0Output
0Input
4 2 1 2 3 4 5 6 7Output
9