問題一覧 > 通常問題

No.1046 Fruits Rush

レベル : / AI推定難易度 : 147 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 520
作問者 : stoq / テスター : fukafukatani
お気に入りにしたユーザー ProblemId : 4131 / 自分の提出
問題文最終更新日: 2020-03-28 00:31:23
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 247 (順位表) の他の問題:

Problem Statement

There are $N$ fruits, and the freshness of the $i$-th fruit is $A_i$.
You will choose at least $1$ and at most $K$ of these fruits to make a mixed juice.
The deliciousness of the mixed juice is defined as the sum of the freshness of the chosen fruits.
Find the maximum possible deliciousness.

Input

$N\ K$
$A_1\ A_2\ \dots \ A_N$

$N,K,A_i$ are integers.
$1 \leq K \leq N \leq 100$
$|A_i| \leq 100$

Output

Output the maximum possible deliciousness. Print a newline at the end.

Sample

Sample 1
Input
3 2
1 3 2
Output
5

It is optimal to choose the fruits with freshness 2, 3.

Sample 2
Input
4 3
1 2 -1 -2
Output
3

It is optimal to choose the fruits with freshness 1, 2.
Note that you do not have to choose exactly $K$ fruits.

Sample 3
Input
5 5
0 0 0 0 0
Output
0

It is neither delicious nor bad.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。