Trains
Due to the increasing number of accidents on the Kostroma-Sudislavl railway line, the railway management has decided to revise the train schedule. A detailed analysis of the track conditions has determined that the optimal schedule for train operations, including station stops, is as follows: the train first travels for t[1]
minutes at a speed of v[1]
meters per minute, then for t[2]
minutes at a speed of v[2]
meters per minute, and so on, until it travels for t[n]
minutes at a speed of v[n]
meters per minute. During some segments, the train may be stationary (speed is 0).
According to current safety regulations, the distance between the locomotives of two consecutive trains must be at least l meters. Your task is to determine the minimum permissible time interval in minutes between train departures that ensures they can follow this schedule without coming dangerously close to each other.
Input
The first two lines contain two natural numbers: the minimum permissible distance l and the number of track segments n (100 ≤ l ≤ 10000, 1 ≤ n ≤ 10000). Following these are n pairs of integers t[i]
and v[i]
(1 ≤ t[i]
≤ 1000, 0 ≤ v[i]
≤ 1000), which describe the train's movement schedule.
Output
Output the required interval between train departures in minutes, with a precision of at least three decimal places.