QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#6605. 女巫森林

Statistiques

沈阳的夜市文化非常发达。每次 Bob 来到沈阳,他一定会去一个叫 The Witchwood 的夜市。The Witchwood 有 $n$ 个小吃摊,第 $i$ 个摊位能给他带来 $a_i$ 的愉悦值。

Bob 的胃最多允许他吃 $k$ 个摊位的小吃。因此,Bob 想知道他在逛完夜市后能获得的最大愉悦值。

输入格式

第一行包含两个整数 $n$ ($1 \le n \le 1000$) 和 $k$ ($1 \le k \le n$),分别表示小吃摊的数量和 Bob 的胃容量。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$),其中第 $i$ 个数表示第 $i$ 个小吃摊的愉悦值。

输出格式

输出一个整数,表示 Bob 能获得的最大愉悦值。

样例

输入 1

5 2
9 8 10 2 4

输出 1

19

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.