AtCoder Beginner Contest 067
B
Snake Toy
AtCoder
⌀ 0
原题
← AC →
翻译中…

Problem Statement

翻译中…

Snuke has $N$ sticks. The length of the $i$-th stick is $l_i$.

翻译中…

Snuke is making a snake toy by joining $K$ of the sticks together.

翻译中…

The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.

翻译中…

Constraints

翻译中…
  • $1 \leq K \leq N \leq 50$
  • $1 \leq l_i \leq 50$
  • $l_i$ is an integer.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K
l_1 l_2 l_3 ... l_{N}

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
5 3
1 2 3 4 5
Output #1
12
You can make a toy of length $12$ by joining the sticks of lengths $3$, $4$ and $5$, which is the maximum possible length.
Input #2
15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45
Output #2
386
题目信息
题号
abc067_b
时间限制
2 s
内存限制
256 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。