#P8295. [COCI 2012/2013 #2] MORTADELA

[COCI 2012/2013 #2] MORTADELA

Background

The score for this problem follows the original COCI setting, with a full score of 5050.

Problem Description

The national supermarket chain (NSC) likes to boast that its mortadella is the cheapest in the country.

In fact, if a customer manages to find cheaper mortadella in another supermarket chain, NSC will refund the difference.

Matej and Filip decide to take on this challenge. They will visit NN different chains one by one, trying to find cooked sausage that is not only cheaper than NSC's, but also the cheapest on the market. If they succeed, they will be able to buy the cheapest sausage at the NSC branch near their school.

NSC hopes that nobody can find cheaper sausage, because all supermarket chains (including NSC) present sausage prices in a complicated way: XX kuna for YY grams of sausage.

Write a program that, given the sausage prices at NSC and the other NN chains, determines how much Matej and Filip must pay for 10001000 grams of cooked sausage at the NSC near their school.

Input Format

The first line contains two positive integers XNSC (1XNSC100)X_{\textrm{NSC}}\ (1\le X_{\textrm{NSC}} \le 100) and YNSC (1YNSC103)Y_{\textrm{NSC}}\ (1\le Y_{\textrm{NSC}} \le 10^3), meaning that XNSCX_{\textrm{NSC}} is the price of YNSCY_{\textrm{NSC}} grams of sausage in the NSC chain.

The second line contains a positive integer N (1N100)N\ (1\le N\le 100), the number of chains (not including NSC).

The next NN lines each contain two positive integers Xi,Yi (Xi100,Yi103)X_i, Y_i\ (X_i\le 100, Y_i\le 10^3), meaning that XiX_i is the price of YiY_i grams of sausage in the ii-th chain.

Output Format

Output a single line containing one real number, the answer rounded to 22 decimal places.

5 100
3
4 100
3 100
7 100
30.00
13 6
5
56 679
35 120
99 999
56 73
37 532
69.55
100 5
3
99 8
65 14
78 10
4642.86

Hint

Translated by ChatGPT 5