Roller coaster velociraptor

You are going to get on a roller coaster when you realize that a velociraptor is coming straigh at you. Fortunately, you have a way to escape: the roller coaster. You know that the velociraptor can follow you through the rail, but he will not fit in the tunnel of the roller coaster. You start to push the car in the platform while the velociraptor is chasing you. For obvious reasons you want to get on the car as soon as possible: you want to obtain the speed enough to reach the tunnel and get rid of the velociraptor, but you do not want to push more than the strictly needed in case it catches you in the platform.

You know all the rises and way down that the roller coaster has. Moreover, you know that for each metre in vertical that goes up, the car loses a speed of KK kilometres per hour, while for each metre in vertical that goes down, recovers the same lost speed of KK kilometres per hour (the laws of physics are not fulfilled in theme parks; if not, it would not have any sense paying so much for the ticket). You also know that there is not any friction with the rail, and that is possible that the car has speed 0 during some moment of the route (you can gather momentum and car would continue) but at any moment it can have negative speed.

Input

The first line of the test data contains the number of cases to solve. Each case starts with 3 integers NN, XX and KK in a line, where NN is the number of stretches of the roller coaster, XX is the coordinate xx of the point where the tunnel is, and KK is the speed in kilometres per hour that is lost (respectively, is won) for each metre gone up (respectively, gone down) in vertical. The following N+1N+1 lines contain N+1N+1 pairs of coordinates (xi,yi)(x_i,y_i), separated by a space, that describe the extremes of the NN straight stretches that the attraction is composed of. It is fulfilled that (x1,y1)(x_1,y_1) is always (0,0)(0,0), and that the xix_i are stricly increasing that is, xi<xi+1x_i < x_{i+1}. Moreover, the tunnel always is in the beginning of a stretch of the roller coaster, that is, exists a point xix_i with 1<iN1<i\leq N such that xi=Xx_i = X.

Output

For each case, your program must print in a line the minimal speed in kilometres per hour which you have to leave the platform with to reach the beginning of the tunnel, assuring that during the whole route the speed of the car is greater or equal than 0.

Scoring

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:58:34.538Z

© Jutge.org, 2006–2026.
https://jutge.org