QOJ.ac

QOJ

実行時間制限: 3.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓

#12212. 最佳子序列

統計

给定一个长度为 $n$ 的数组 $w_1, w_2, \dots, w_n$。 你需要选择一个长度为 $k$ 的子序列。设其下标为 $1 \le i_1 < i_2 < \dots < i_k \le n$。 你的目标是在所有此类子序列中,找到以下表达式的最小值: $$\max((w_{i_1} + w_{i_2}), (w_{i_2} + w_{i_3}), \dots, (w_{i_{k-1}} + w_{i_k}), (w_{i_k} + w_{i_1}))$$

输入格式

第一行包含两个整数 $n$ 和 $k$:数组 $w$ 的元素个数以及子序列的长度 ($3 \le k \le n \le 200\,000$)。 第二行包含 $n$ 个空格分隔的整数 $w_1, w_2, \dots, w_n$ ($1 \le w_i \le 10^9$)。

输出格式

输出一个整数:在所有长度为 $k$ 的子序列中,上述表达式的最小值: $$\max((w_{i_1} + w_{i_2}), (w_{i_2} + w_{i_3}), \dots, (w_{i_{k-1}} + w_{i_k}), (w_{i_k} + w_{i_1}))$$

样例

输入 1

5 3
17 18 17 30 35

输出 1

35

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#541Editorial Open集训队作业 解题报告 by 林祺昊Qingyu2026-01-02 22:01:41 Download

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.