QOJ.ac

QOJ

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

#15394. Buses

统计

有一条长度为 $\ell$ 米的笔直道路,位置 $p$ 表示道路上距离起点 $p$ 米的点。在这条道路上,有 $n$ 辆公交车正沿正方向行驶,每辆车的速度均为恒定的 $x$ 米/分钟。第 $i$ 辆公交车当前位于位置 $s_i$,并将持续行驶直到到达其指定终点 $t_i$。一旦公交车到达终点,它将停止运行,所有乘客必须下车。

此外,有 $m$ 个人希望到达道路的尽头(位置 $\ell$)。第 $i$ 个人的当前位置为 $p_i$,每个人步行的速度最大为 $y$ 米/分钟。如果一个人与公交车处于同一位置,他们可以立即上车。在乘车过程中,他们可以随时下车。上车或下车所需的时间忽略不计。公交车始终以恒定速度 $x$ 行驶,且从不等待乘客。

你的任务是确定每个人到达道路尽头所需的最短时间。

图 1:样例输入 1 的示意图。

输入格式

第一行包含五个整数 $n$、$m$、$\ell$、$x$ 和 $y$,分别表示公交车的数量、人的数量、道路长度、公交车速度和人的步行速度。

接下来的 $n$ 行,第 $i$ 行包含两个整数 $s_i$ 和 $t_i$,表示第 $i$ 辆公交车的起始位置和终点位置。

接下来的 $m$ 行,第 $i$ 行包含一个整数 $p_i$,表示第 $i$ 个人的当前位置。

  • $1 \le n \le 2 \times 10^5$
  • $1 \le m \le 2 \times 10^5$
  • $1 \le \ell \le 10^9$
  • $1 \le y < x \le 10^6$
  • $0 \le s_i < t_i \le \ell$
  • $0 \le p_i \le \ell$

输出格式

输出 $m$ 行。第 $i$ 行包含一个数字,表示第 $i$ 个人到达道路尽头所需的最短时间(分钟)。

如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则视为正确。形式化地,设你的答案为 $a$,标准答案为 $b$,若满足 $\frac{|a-b|}{\max(1,|b|)} \le 10^{-6}$,则你的答案被视为正确。

样例

输入 1

3 3 10 4 1
0 5
2 4
7 9
3
8
5

输出 1

6.25
1.5
5

输入 2

1 3 100 100 1
1 2
0
1
2

输出 2

100
98.01
98

说明

样例 1 的解释:初始位置为 $p = 3$ 的人可以通过以下方式在 6.25 分钟内到达道路尽头:

  • 等待公交车 1 到达。
  • 上车并乘坐至其终点 $t_1 = 5$。
  • 下车并步行剩余距离至位置 $\ell = 10$。

如图 1 所示,总耗时为 6.25 分钟,这是可能的最短时间。

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.