#P10285. [USACO24OPEN] Activating Robots P

[USACO24OPEN] Activating Robots P

题目描述

You and a single robot are initially at point 00 on a circle with perimeter LL (1L1091 \le L \le 10^9). You can move either counterclockwise or clockwise along the circle at 11 unit per second. All movement in this problem is continuous.

Your goal is to place exactly R1R-1 robots such that at the end, every two consecutive robots are spaced L/RL/R away from each other (2R202\le R\le 20, RR divides LL). There are NN (1N1051\le N\le 10^5) activation points, the iith of which is located aia_i distance counterclockwise from 00 (0ai<L0\le a_i<L). If you are currently at an activation point, you can instantaneously place a robot at that point. All robots (including the original) move counterclockwise at a rate of 11 unit per KK seconds (1K1061\leq K\leq 10^6).

Compute the minimum time required to achieve the goal.

输入格式

The first line contains LL, RR, NN, and KK.

The next line contains NN space-separated integers a1,a2,,aNa_1,a_2,\dots,a_N.

输出格式

The minimum time required to achieve the goal.

10 2 1 2
6
22
10 2 1 2
7
4
32 4 5 2
0 23 12 5 11
48
24 3 1 2
16
48

提示

For Sample 1:

We can reach the activation point at 66 in 44 seconds by going clockwise. At this time, the initial robot will be located at 22. Wait an additional 1818 seconds until the initial robot is located at 11. Now we can place a robot to immediately win.

For Sample 2:

We can reach the activation point at 77 in 33 seconds by going clockwise. At this time, the initial robot will be located at 1.51.5. Wait an additional second until the initial robot is located at 22. Now we can place a robot to immediately win.

SCORING:

  • Inputs 5-6: R=2R=2.
  • Inputs 7-12: R10,N80R\le 10, N\le 80.
  • Inputs 13-20: R16R\le 16.
  • Inputs 21-24: No additional constraints.