QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#9282. 格列布与铸造厂大街

Statistics

Gleb 刚在 Nekrasova 街的一家酒吧度过了一段美好时光,现在正前往他的住处——Indigo 酒店。他的路径沿着 Liteyny 大道,我们将其视为一条完美的直线。

为了解决这个问题,Gleb 只在大道上及其两侧移动。他现在位于大道上的点 $0$,而他要去的酒店位于点 $L$。此外,酒店位于大道的另一侧。在 Gleb 和 Indigo 之间有 $n$ 个人行横道,第 $i$ 个横道位于整数坐标点 $x_i$。为了到达酒店,Gleb 需要走完从点 $0$ 到点 $L$ 的整段大道,并在这次行程中的某个时刻穿过街道。

所有的横道都配有交通信号灯。这些交通信号灯的周期长度相同。它们绿灯持续 $g$ 秒,红灯持续 $r$ 秒。然而,它们并不是同步的,即每个交通信号灯都有一些随机且等概率的周期偏移。所有偏移量均为整数,因此总共有 $r + g$ 种可能的偏移量。Gleb 知道整数 $r$ 和 $g$,但在开始时他对偏移量一无所知。

每个横道的交通信号灯都有一个计时器,显示该交通信号灯周期的当前状态。如果灯是绿色的,计时器显示距离绿灯结束还有多少秒;如果灯是红色的,计时器显示距离变绿还需要等待多少秒。Gleb 只有在到达该横道和交通信号灯所在的精确位置时,才能观察到灯的颜色和计时器的状态。好消息是,Gleb 能够记住他在这次步行中所看到的一切,因此他会记住所经过的所有交通信号灯的当前状态。

所有坐标均为整数,单位为米。Gleb 以每秒一米的速度移动。此外,已知人行横道分布并不太频繁。形式上,在 $g + r$ 米的范围内不存在三个横道。

Gleb 可以沿着大道向任意方向移动,并可以穿过街道任意多次。穿过街道需要 $b$ 秒,且在此期间交通信号灯必须保持绿灯。

输入格式

第一行包含整数 $n, L, g, r$ 和 $b$ ($1 \le n \le 100\,000, 1 \le L, g, r \le 10^9, 1 \le b \le g$),分别表示大道上的横道数量、Gleb 与 Indigo 酒店之间的初始距离(单位:米)、交通信号灯绿灯持续时间(单位:秒)、交通信号灯红灯持续时间(单位:秒)以及 Gleb 穿过街道所需的时间(单位:秒)。

接下来 $n$ 行描述横道的位置 $x_1, x_2, \dots, x_n$ ($0 < x_1 < x_2 < \dots < x_n < L$)。保证对于所有 $1 \le i \le n - 2$,满足 $x_{i+2} - x_i > g + r$。

输出格式

输出一个实数,表示 Gleb 在采取最优策略的情况下到达 Indigo 酒店的期望时间。绝对或相对误差不应超过 $10^{-9}$。

样例

输入 1

1 10 2 4 1
2

输出 1

12.6666666666667

输入 2

2 820 30 50 23
400
810

输出 2

866.0250000000000

输入 3

3 100 20 50 1
10
15
85

输出 3

107.6141690962099

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.