410176: GYM103968 B Sour Skittles

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Sour Skittlestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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.

Input

The 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.

Output

Output a single integer, the sum of the sourness of all Skittles that you choose to consume.

ExamplesInput
6
5
1 5 3 2 0
Output
0
Input
4
2
1 2 3 4 5 6 7
Output
9

加入题单

算法标签: