#C3256. Maximum Number of Cakes
Maximum Number of Cakes
Maximum Number of Cakes
You are given a recipe with the required amounts of each ingredient needed to bake one cake and a list of available amounts for various ingredients. Your task is to determine the maximum number of cakes you can bake using the available ingredients. For each ingredient \(i\) in the recipe, if the required amount is \(r_i\) and the available amount is \(a_i\), the maximum number of cakes you can bake using that ingredient is given by \(\left\lfloor \frac{a_i}{r_i} \right\rfloor\). The answer is the minimum of these values across all ingredients in the recipe.
Note: If an ingredient required by the recipe is not available, you cannot bake any cakes.
inputFormat
The input is given via standard input (stdin) in the following format:
- An integer \(r\) representing the number of ingredients in the recipe.
- The next \(r\) lines each contain a string and an integer. The string is the name of the ingredient and the integer represents the required amount for one cake.
- An integer \(a\) representing the number of available ingredients.
- The next \(a\) lines each contain a string and an integer. The string is the name of the ingredient and the integer represents the available amount.
Any ingredient not listed in the available ingredients is considered to have an amount of 0.
outputFormat
Output a single integer to standard output (stdout) representing the maximum number of cakes that can be baked.
## sample3
flour 500
sugar 200
eggs 1
3
flour 1200
sugar 1200
eggs 5
2