QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#8450. 露营大会

统计

图片由 Freepik 上的 brgfx 提供

一群童子军正准备去参加与其他童子军的大型聚会。他们的领队 Hildeborg 本着童子军“时刻准备着”的座右铭,想要在童子军中分发一些他们冒险时最可能需要的实用物品。这些物品的大小各不相同,为了尽可能公平,她希望确保任何一名童子军所携带物品的总大小尽可能小。此外,Hildeborg 不希望给任何一名童子军超过两件物品,因为她担心这样会让他们难以记住带齐所有东西。给定物品的大小,任何一名童子军所必须携带的物品总大小的最大值最小是多少?

输入格式

输入的第一行包含两个正整数 $N$ 和 $M$ ($1 \le N \le 2M$, $1 \le M \le 100$)。$N$ 是实用物品的数量,$M$ 是童子军的数量。第二行包含 $N$ 个正整数 $a_i$ ($1 \le a_i \le 10^7$),表示物品的大小。

输出格式

输出一个整数,表示任何一名童子军所必须携带的物品总大小的最大值中的最小值。

样例

样例输入 1

3 4
10 10 10

样例输出 1

10

样例输入 2

5 4
9 12 3 9 10

样例输出 2

12

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.