No tags yet

No tag edit access

В условии задачи недавно были сделаны правки. Просмотреть изменения.

×
time limit per test: 0.25 sec.

memory limit per test: 4096 KB

memory limit per test: 4096 KB

input: standard input

output: standard output

output: standard output

The runner moves along the ring road with length L. His way consists of N intervals. First he ran T1 minutes with speed V1, then T2 minutes with speed V2 and so on till the N-th interval, where he ran TN minutes with speed VN. Your task is to find the distance from start to finish along the ring road. The distance along the ring road is the length of the shortest way all points of which belongs to the ring road.

Real number L (1<=L<=1000, with 4 signs after decimal point) and natural number N (N<=20000) are written in the first line. Each of the following N lines contains two integer numbers Ti and Vi (1<=Ti<=10^7, 1<=Vi<=10^6).

Write the only one real number with 4 digits after decimal points: the distance from start to finish.

Input

2 1

1 3

1 3

Output

1.0000

Author: | Michael R. Mirzayanov |

Resource: | Summer School Team Contest, 2002 |

Date: | August, 2002 |

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/30/2020 19:46:59 (i2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|