#P1870. 公交车

公交车

Description

A city has a parking lot that can hold nn buses. Each day, these buses leave the depot in order and head to a terminal that is dd meters away. The ii-th bus leaves the parking lot at time tit_i seconds, travels with a maximum speed no greater than viv_i meters per second, and has a maximum acceleration of aa. A bus can decelerate instantaneously and can change its acceleration instantaneously. The maximum acceleration is the same for every bus and equals aa.

No matter how powerful a bus is, it may not overtake any other bus. If a bus catches up with another, the rear bus and the front bus travel side by side together and reach the terminal at the same time. Drivers always try to reach the terminal as fast as possible.

As the bus company owner, you want every bus to reach the terminal as quickly as possible. It is not required that the bus speed be 00 upon arrival at the terminal. When a bus leaves the parking lot, its initial speed is 00. From a physics perspective, treat a bus as an abstract point-like object; apart from being able to accelerate and decelerate, all other effects on speed can be ignored.

Input Format

The first line contains three space-separated integers n,a,dn, a, d (1n1051 \leq n \leq 10^5, 1a,d1061 \leq a, d \leq 10^6), denoting the number of buses, the maximum acceleration, and the distance to the terminal, respectively.

The next nn lines each contain a pair of integers ti,vit_i, v_i ($0 \leq t_1 < t_2 < \cdots < t_{n-1} < t_n \leq 10^6$, 1vi1061 \leq v_i \leq 10^6), denoting the departure time of each bus and its maximum possible speed, respectively.

Output Format

Output the arrival time at the terminal for each bus. Print one bus’s arrival time per line, in the same order as the input. The relative or absolute error of each answer must not exceed 10410^{-4} (i.e., keep 4 decimal places at the end).

3 10 10000
0 10
5 11
1000 1

1000.5000
1000.5000
11000.0500

Hint

[Sample explanation]

The second bus can catch up with the first bus at a point 510.5510.5 kilometers from the terminal. Then there are 9489.59489.5 kilometers remaining, and both buses travel together at 1010 km/h to reach the terminal at time 1000.51000.5 seconds. The third bus cannot catch up with any other bus, and its arrival time is 11000.0511000.05 seconds.

Translated by ChatGPT 5