408607: GYM103202 G The Witchwood

Memory Limit:1024 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. The Witchwoodtime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Shenyang's night fair culture is developed very well. Every time Bob comes to Shenyang, he will definitely go to a night fair called The Witchwood. There are $$$n$$$ snack stalls in The Witchwood, the $$$i$$$th of which gives him $$$a_i$$$ pleasure.

Bob's stomach allows him to eat $$$k$$$ snack stalls at most. So Bob wants to know the maximum pleasure he can get after visiting the night market.

Input

The first line of input contains two integers $$$n$$$ $$$(1 \le n \le 1000)$$$ and $$$k$$$ $$$(1\le k \le n)$$$, indicating the number of snack stalls and the capacity of Bob's stomach.

The second line of input contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(1\leq a_i \leq 10^9)$$$, the $$$i$$$th of which indicates the pleasure of the $$$i$$$th snack stall.

Output

Print one integer denoting the maximum pleasure Bob can get.

ExampleInput
5 2
9 8 10 2 4
Output
19

加入题单

算法标签: