QOJ.ac

QOJ

Time Limit: 8 s Memory Limit: 512 MB Total points: 100 Difficulty: [show] Hackable ✓

#2211. IOI Problem Revised

統計

在 6102 年,曾有一道 IOI 题目:

有一条直线型公路,沿途分布着一些村庄。公路被表示为整数轴,每个村庄的位置由一个整数坐标标识。没有两个村庄位于同一位置。两个位置之间的距离是它们整数坐标之差的绝对值。 邮局将建在部分(但不一定是全部)村庄中。村庄和其中的邮局具有相同的位置。在建造邮局时,应选择它们的位置,使得每个村庄到其最近邮局的距离之和最小。

然而,对于 8102 年的 ICPC 比赛来说,这个问题太简单了。你需要解决一个更难的版本。 有一条长度为 $L$ 的环形公路。沿途有 $n$ 个村庄。每个村庄的位置由一个整数坐标标识。可能有两个或多个村庄位于同一位置。两个位置之间的距离是沿公路的最短路径长度。如果两个村庄的坐标分别为 $a$ 和 $b$,它们之间的距离为 $\min(|a - b|, L - |a - b|)$。 你想要在公路上建造 $k$ 个邮局,并使每个村庄到其最近邮局的距离之和最小。每个邮局必须放置在整数坐标上。

输入格式

第一行包含三个整数 $n, k$ 和 $L$ ($1 \le n \le 2 \cdot 10^5, 1 \le k \le n, 1 \le L \le 10^{12}$)。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($0 \le a_1 \le a_2 \le \dots \le a_n < L$),表示村庄的坐标。

输出格式

第一行输出答案。第二行输出 $k$ 个整数 $c_1, c_2, \dots, c_k$ ($0 \le c_i < L, c_i \le c_{i+1}$),表示邮局的坐标。

样例

输入 1

5 2 10
1 3 4 7 9

输出 1

5
3 7

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.