Welcome   HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online
Home
FAQs
Problem Set
Practices
Online Contests
Major Exercises
OI Special
Judgement
Submit
Online Status
User Ranklist
Users
Register new
Login
Web Links
Hunan Normal University
College of Mathematics and Computer Science
Fast Ride
Time Limit: 1500ms, Special Time Limit:2500ms, Memory Limit:32768KB
Total submit users: 3, Accepted users: 2
Problem 10047 : No special judgement
Problem description
  Is there a Russian who does not like a fast ride?! Royal messenger should get from point A to point B as quickly as possible. Point A has coordinate 0 on the Ox axis. Point B has positive coordinate B on the Ox axis. Of course, the messenger will use horses to get to the destination point. The messenger is not allowed to travel by foot because of an importance of his mission and security reasons.

There are N stables on the straight line from A to B. The i-th stable has Mi horses inside. Each horse is characterized by its speed vj and maximum distance it can gallop dj (after that it falls exhausted). The messenger can change the horse reaching or passing a stable to any horse from that stable without losing time.

Your task is to find the minimum time the messenger needs to get to the point

Input
  The first line of the input contains two integer numbers B and N (1 B 108; 1 N 5000), where N is the number of stables. Descriptions of the stables follow. The first line of each description contains two integer numbers Xi, Mi (0 Xi 108; 0 < Mi) ?the position of the stable and the number of horses in this stable respectively. The following Mi lines contain the description of the horses. Each description of a horse is a pair of integer numbers vj, dj (1 vj 108; 1 dj 108). The total number of horses in all stables is no more than 105. It is possible that two or more stables have the same position.

Output
  Write the minimum time which will take the messenger to get to the point B to the output. The answer should be written with 3 digits after the decimal point. If the solution does not exist, write -1 to the output.

Sample Input
10 3
5 2
1 100
10 3
0 1
1 50
8 1
2 3
Sample Output
6.300
Problem Source
  SSU 

Submit   Discuss   Judge Status  Problems  Ranklist 

HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online, Version 2010.5.5.final.
Web visits:5825 today,10453926 total, since 2010-05-07