P8295 [COCI 2012/2013 #2] MORTADELA

Background

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

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 $N$ 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: $X$ kuna for $Y$ grams of sausage. Write a program that, given the sausage prices at NSC and the other $N$ chains, determines how much Matej and Filip must pay for $1000$ grams of cooked sausage at the NSC near their school.

Input Format

The first line contains two positive integers $X_{\textrm{NSC}}\ (1\le X_{\textrm{NSC}} \le 100)$ and $Y_{\textrm{NSC}}\ (1\le Y_{\textrm{NSC}} \le 10^3)$, meaning that $X_{\textrm{NSC}}$ is the price of $Y_{\textrm{NSC}}$ grams of sausage in the NSC chain. The second line contains a positive integer $N\ (1\le N\le 100)$, the number of chains (not including NSC). The next $N$ lines each contain two positive integers $X_i, Y_i\ (X_i\le 100, Y_i\le 10^3)$, meaning that $X_i$ is the price of $Y_i$ grams of sausage in the $i$-th chain.

Output Format

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

Explanation/Hint

Translated by ChatGPT 5