#P9240. Magical Furnace Conversion Rate
Magical Furnace Conversion Rate
Magical Furnace Conversion Rate
Little Blue has a magical furnace used to refine ordinary metal O into a special metal X. The furnace has a property called the conversion rate \(V\), a positive integer, meaning that exactly \(V\) units of O are needed to produce one unit of X. If the available O is less than \(V\), no X can be produced in that operation.
You are given \(N\) independent furnace operation records. Each record contains two integers \(A\) and \(B\), where \(A\) is the number of ordinary metal O input and \(B\) is the number of special metal X obtained. Note that leftovers from one record are not carried over to the next.
For a record with \(B > 0\), the process implies that
\(\frac{A}{B+1} < V \leq \frac{A}{B}\).
For a record with \(B = 0\), since no X is produced, we must have
\(V > A\).
Your task is to determine the minimum and maximum possible integer values of \(V\) that satisfy all \(N\) records. If the maximum possible \(V\) is unbounded, output -1 for the maximum.
inputFormat
The first line contains a single integer \(N\), the number of records.
Each of the following \(N\) lines contains two space-separated integers \(A\) and \(B\) representing one furnace operation record.
outputFormat
Output two integers separated by a space: the minimum and maximum possible values of \(V\) that satisfy all the records. If the maximum is unbounded, output -1 as the second number.
sample
3
13 4
9 3
11 3
3 3