CF2172B.Buses
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a long straight road of length ℓ meters, where position p denotes the point on the road that is p meters away from the starting point. Along this road, there are n buses moving in the positive direction, each traveling at the same constant speed of x meters per minute. The i-th bus is currently at position si and continues moving until it reaches its designated destination at position ti. Once a bus reaches its destination, it ceases operation and all passengers must disembark.
There are also m people who wish to reach the end of the road (position ℓ). The current position of the i-th person is pi, and each person can walk at a speed of at most y 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 x 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.
有一条长度为 ℓ 米的笔直长路,其中位置 p 表示距离起点 p 米处的点。沿此道路有 n 辆公交车正朝正方向行驶,每辆车均以恒定速度 x 米/分钟运行。第 i 辆车当前位于位置 si,并持续行驶直至抵达其指定终点位置 ti。一旦某辆公交车到达其终点,即停止运行,所有乘客必须下车。
此外还有 m 位行人希望抵达道路尽头(即位置 ℓ)。第 i 位行人当前位于位置 pi,且每位行人步行速度至多为 y 米/分钟。若某行人与某辆公交车处于同一位置,则可立即上车;在乘车过程中,亦可在任意时刻下车。上下车所需时间忽略不计。公交车始终以恒定速度 x 行驶,且从不为乘客停留。
你的任务是求出每位行人抵达道路尽头所需的最短时间。
图 1:样例输入 1 的示意图。
输入格式
The first line contains five integers n, m, ℓ, x and y, 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 i-th of the following n lines contains two integers si and ti, representing the starting position and the destination position of the i-th bus.
The i-th of the following m lines contains one integer pi, representing the current position of the i-th person.
- 1≤n≤2×105
- 1≤m≤2×105
- 1≤ℓ≤109
- 1≤y<x≤106
- 0≤si<ti≤ℓ
- 0≤pi≤ℓ
第一行包含五个整数 n、m、ℓ、x 和 y,分别表示公交车的数量、人数、道路长度、公交车速度以及人的步行速度。
接下来的 n 行中,第 i 行包含两个整数 si 和 ti,表示第 i 辆公交车的起始位置和目的地位置。
再接下来的 m 行中,第 i 行包含一个整数 pi,表示第 i 个人当前所处的位置。
- 1≤n≤2×105
- 1≤m≤2×105
- 1≤ℓ≤109
- 1≤y<x≤106
- 0≤si<ti≤ℓ
- 0≤pi≤ℓ
输出格式
Print m lines. The i-th line contains a number which is the minimum time (in minutes) for the i-th person to reach the end of the road.
Your answer will be accepted if the absolute or relative error does not exceed 10−6. Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if max(1,∣b∣)∣a−b∣≤10−6.
输出 m 行。第 i 行包含一个数字,表示第 i 个人到达道路终点所需的最短时间(单位:分钟)。
若你的答案的绝对误差或相对误差不超过 10−6,则该答案被接受。形式化地,设你的答案为 a,评测组的答案为 b,当且仅当 max(1,∣b∣)∣a−b∣≤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=3 can reach the end of the road in 6.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=5.
- Get off the bus and walk the remaining distance to position ℓ=10.
As shown in Figure 1, the total time spent is 6.25 minutes, which is the minimum possible.
样例 1 解释:一名初始位于位置 p=3 的人可按如下方式在 6.25 分钟内抵达道路终点:
- 等待公交 1 到达;
- 上车并乘坐该公交车,直至其抵达目的地位置 t1=5;
- 下车后步行剩余距离至位置 ℓ=10。
如图 1 所示,总耗时为 6.25 分钟,此即可能的最短时间。
输入解题思路,AI测评打分。不知道怎么写?