QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 256 MB Points totaux : 100

#8541. 激活机器人

Statistiques

你和一个机器人最初位于周长为 $L$ ($1 \le L \le 10^9$) 的圆上的点 $0$ 处。你可以以每秒 $1$ 个单位的速度沿圆周进行逆时针或顺时针移动。本题中的所有移动均为连续的。

你的目标是放置恰好 $R-1$ 个机器人,使得最终每两个相邻机器人之间的距离均为 $L/R$ ($2\le R\le 20$,$R$ 整除 $L$)。共有 $N$ ($1\le N\le 10^5$) 个激活点,其中第 $i$ 个激活点位于距离 $0$ 点逆时针 $a_i$ 的位置 ($0\le a_i

计算达成目标所需的最短时间。

输入格式

第一行包含 $L, R, N, K$。

第二行包含 $N$ 个空格分隔的整数 $a_1, a_2, \dots, a_N$。

输出格式

达成目标所需的最短时间。

样例

样例输入 1

10 2 1 2
6

样例输出 1

22

说明 1

我们可以通过顺时针移动,在 $4$ 秒内到达位于 $6$ 的激活点。此时,初始机器人将位于 $2$。再等待 $18$ 秒,直到初始机器人位于 $1$。现在我们可以放置一个机器人并立即获胜。

样例输入 2

10 2 1 2
7

样例输出 2

4

说明 2

我们可以通过顺时针移动,在 $3$ 秒内到达位于 $7$ 的激活点。此时,初始机器人将位于 $1.5$。再等待 $1$ 秒,直到初始机器人位于 $2$。现在我们可以放置一个机器人并立即获胜。

样例输入 3

32 4 5 2
0 23 12 5 11

样例输出 3

48

样例输入 4

24 3 1 2
16

样例输出 4

48

子任务

  • 输入 5-6: $R=2$
  • 输入 7-12: $R\le 10, N\le 80$
  • 输入 13-20: $R\le 16$
  • 输入 21-24: 无额外限制。

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.