JDCC '16 Contest 5 P4 - Space Invaders

View as PDF

Points: 10
Time limit: 3.0s
Memory limit: 256M

Author:
Problem types

The SETI signal is indisputable - an alien invasion of Flatland is imminent. The aliens have sent N ships, each of which has been determined to be at some position and moving vertically down towards Flatland at velocity . Flatland is situated on the -axis between and .

Once a ships land, it is expected that the aliens will spread out across Flatland at a rate of . They have a large technological advantage and Flatland’s current defenses will be no match for the invaders. However, there is still hope: a secret research weapon is being built which, if completed, will be able to push back the aliens.

As Flatland’s head of defense, you have been tasked with determining how long it will take for the invaders to entirely conquer Flatland. Using your estimate, the researchers will work hard to prepare the weapon in time. Don’t let them down!

Input

Each test case begins with two integers . The next lines each contain integers , which represent the location of a ship, how fast it is moving, and how fast the aliens will spread out from the ship once it lands.

Output

For each test case, output, on one line, the time until Flatland is conquered, rounded to two decimal places.

Sample Input

1 5
0 3 1 2

Sample Output

5.50

Sample Input

2 4
-2 5 5 1
2 5 2 2

Sample Output

3.50

Explanation of the Sample Input

In the second case, the first ship touches down at after second and the aliens begin spreading out at a rate of one unit per second. After seconds, the second ship touches down, at which point the first ship has conquered the section of Flatland. The aliens then spread out from the second ship at a rate of units per second, conquering the remaining portion of Flatland in one second.

Comments

There are no comments at the moment.