CF2172B.Buses

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a long straight road of length ℓ\ell meters, where position pp denotes the point on the road that is pp meters away from the starting point. Along this road, there are nn buses moving in the positive direction, each traveling at the same constant speed of xx meters per minute. The ii-th bus is currently at position sis_i and continues moving until it reaches its designated destination at position tit_i. Once a bus reaches its destination, it ceases operation and all passengers must disembark.

There are also mm people who wish to reach the end of the road (position ℓ\ell). The current position of the ii-th person is pip_i, and each person can walk at a speed of at most yy meters per minute. If a person is at the same position as a bus, they may hop on the bus instantly. While riding a bus, they may hop off at any moment. The time required to board or leave a bus is considered negligible. Buses always move at a constant speed xx and never wait for passengers.

Your task is to determine the minimum possible time for each person to reach the end of the road.

Figure 1: An illustration for sample input 1.

有一条长度为 ℓ\ell 米的笔直长路,其中位置 pp 表示距离起点 pp 米处的点。沿此道路有 nn 辆公交车正朝正方向行驶,每辆车均以恒定速度 xx 米/分钟运行。第 ii 辆车当前位于位置 sis_i,并持续行驶直至抵达其指定终点位置 tit_i。一旦某辆公交车到达其终点,即停止运行,所有乘客必须下车。

此外还有 mm 位行人希望抵达道路尽头(即位置 ℓ\ell)。第 ii 位行人当前位于位置 pip_i,且每位行人步行速度至多为 yy 米/分钟。若某行人与某辆公交车处于同一位置,则可立即上车;在乘车过程中,亦可在任意时刻下车。上下车所需时间忽略不计。公交车始终以恒定速度 xx 行驶,且从不为乘客停留。

你的任务是求出每位行人抵达道路尽头所需的最短时间。

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

输入格式

The first line contains five integers nn, mm, ℓ\ell, xx and yy, representing the number of buses, the number of people, the length of the road, the speed of the buses, and the walking speed of the people, respectively.

The ii-th of the following nn lines contains two integers sis_i and tit_i, representing the starting position and the destination position of the ii-th bus.

The ii-th of the following mm lines contains one integer pip_i, representing the current position of the ii-th person.

  • 1≤n≤2×1051 \leq n \leq 2 \times 10^5
  • 1≤m≤2×1051 \leq m \leq 2 \times 10^5
  • 1≤ℓ≤1091 \leq \ell \leq 10^9
  • 1≤y<x≤1061 \leq y \lt x \leq 10^6
  • 0≤si<ti≤ℓ0 \leq s_i \lt t_i \leq \ell
  • 0≤pi≤ℓ0 \leq p_i \leq \ell

第一行包含五个整数 nn、mm、ℓ\ell、xx 和 yy,分别表示公交车的数量、人数、道路长度、公交车速度以及人的步行速度。

接下来的 nn 行中,第 ii 行包含两个整数 sis_i 和 tit_i,表示第 ii 辆公交车的起始位置和目的地位置。

再接下来的 mm 行中,第 ii 行包含一个整数 pip_i,表示第 ii 个人当前所处的位置。

  • 1≤n≤2×1051 \leq n \leq 2 \times 10^5
  • 1≤m≤2×1051 \leq m \leq 2 \times 10^5
  • 1≤ℓ≤1091 \leq \ell \leq 10^9
  • 1≤y<x≤1061 \leq y \lt x \leq 10^6
  • 0≤si<ti≤ℓ0 \leq s_i \lt t_i \leq \ell
  • 0≤pi≤ℓ0 \leq p_i \leq \ell

输出格式

Print mm lines. The ii-th line contains a number which is the minimum time (in minutes) for the ii-th person to reach the end of the road.

Your answer will be accepted if the absolute or relative error does not exceed 10−610^{-6}. Formally, let your answer be aa, and the jury's answer be bb. Your answer is considered correct if ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{\left\vert a - b \right\vert}{\max(1, \left\vert b \right\vert)} \leq 10^{-6}.

输出 mm 行。第 ii 行包含一个数字,表示第 ii 个人到达道路终点所需的最短时间(单位:分钟)。

若你的答案的绝对误差或相对误差不超过 10−610^{-6},则该答案被接受。形式化地,设你的答案为 aa,评测组的答案为 bb,当且仅当 ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{\left\vert a - b \right\vert}{\max(1, \left\vert b \right\vert)} \leq 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

说明/提示

Explanation of Sample 1: A person initially at position p=3p = 3 can reach the end of the road in 6.256.25 minutes as follows:

  • Wait for Bus 1 to arrive.
  • Hop on the bus and ride it until it reaches its destination at position t1=5t_1 = 5.
  • Get off the bus and walk the remaining distance to position ℓ=10\ell = 10.

As shown in Figure 1, the total time spent is 6.256.25 minutes, which is the minimum possible.

样例 1 解释:一名初始位于位置 p=3p = 3 的人可按如下方式在 6.256.25 分钟内抵达道路终点:

  • 等待公交 1 到达;
  • 上车并乘坐该公交车,直至其抵达目的地位置 t1=5t_1 = 5;
  • 下车后步行剩余距离至位置 ℓ=10\ell = 10。

如图 1 所示,总耗时为 6.256.25 分钟,此即可能的最短时间。

输入解题思路,AI测评打分。不知道怎么写?

首页