All Submissions


N persons have taken part in a race which consists of x Km Hurdle Race & y Km swimming.
Each racer has his own swimming & running speed.
Organizers have been bribed by the Nth person to set x and y so that he can win by the maximum margin.
You are to determine if this is possible and, if so, give x and y.

INPUT:
Input contains many test cases (<=10000)
First line of each case the gives total race distance (in km)
Next line gives number of competitors n.
Next N lines gives running & swimming speed for that person in (km/hr).

OUTPUT:
If it is possible to fix the race , print x and y accurate to two decimal places,
and the amount of seconds by which the Nth person will win the race.
If it is not possible to fix the race print -1

Sample Input:
100
3
10.0 30.0
20.0 20.0
15.0 35.0
100
3
10.0 40.0
20.0 30.0
15.0 15.5

Sample Output:
25.00 75.00 4286
-1


N,x,y < 10^4
use ternary search
Problem Setter: Jayant Mukherji

Languages: Brain,C,C++,Java,C#,JavaScript,Pascal,Perl,PHP,Python,Ruby,Text

Time Limit: 1 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0