Radio-Controlled Car Race
InterviewTime limit2sMemory limit1024 MB
Given each car's head start and constant speed, find the earliest time at which two cars are at the same distance from the start.
- Level
Easy2 of 10
- Topics
- Brute force, Math
- Solved
- No attempts yet
Problem
Like every boy, Fedya has toy cars. He is lucky, though: all of his cars are radio-controlled. He spends whole days organizing different car races with his friends.
Of all race formats, Fedya likes straight-line races best. In this format the track is a straight line with no end. The race lasts until Fedya gets bored. At the start, each car is some distance from the starting line. This head start is meters for car . On the signal, all cars start moving from the starting line, and each car moves at a constant speed of meters per second. All cars move in the same direction, away from the start.
Fedya recently received a video camera and wants to film the highlights of the race. Above all, he wants to capture the first overtake, that is, the first moment when two cars are at the same distance from the start.
This event could take a long time to happen, so Fedya wants to set the camera to start recording automatically during an overtake. However, he cannot work out by himself how much time passes from the start of the race until the first overtake. Write a program that finds this value.
Input
The first line contains one integer , the number of cars on the track (). Each of the next lines contains two integers and , the distance from the start in meters and the speed of car in meters per second ().
Initially, no two cars are at the same point. It is guaranteed that at least one overtake happens during the race.
Output
Print the number of seconds from the start until the first overtake, with an accuracy of at least 5 digits after the decimal point.
Hint
In the figure below, point marks the place where the overtake happens.
