#C8479. Maximum Cookies
Maximum Cookies
Maximum Cookies
You are given two ingredients: flour (f) and sugar (s), and a list of cookie recipes. Each recipe requires a specific amount of flour and sugar. Your task is to determine the maximum number of cookies you can bake using one of the given recipes.
For a cookie recipe that requires \(f_i\) units of flour and \(s_i\) units of sugar, the maximum number of cookies that can be baked using that recipe is given by:
\( \text{cookies} = \min\left(\left\lfloor \frac{f}{f_i}\right\rfloor, \left\lfloor \frac{s}{s_i}\right\rfloor\right) \)
Select the recipe that allows you to bake the largest number of cookies.
inputFormat
The input consists of multiple lines:
- The first line contains two integers \(f\) and \(s\), representing the available amounts of flour and sugar respectively.
- The second line contains an integer \(n\), the number of cookie recipes.
- Each of the following \(n\) lines contains two integers \(f_i\) and \(s_i\), indicating the amount of flour and sugar required for that cookie recipe.
All input is read from standard input (stdin).
outputFormat
Output a single integer representing the maximum number of cookies that can be baked using the optimal recipe. The result should be printed to standard output (stdout).
## sample100 200
2
10 20
5 30
10