#P9240. [蓝桥杯 2023 省 B] 冶炼金属

[蓝桥杯 2023 省 B] 冶炼金属

Problem Description

Xiao Lan has a magical furnace that can smelt ordinary metal O into a special metal X. The furnace has a property called the conversion rate VV. VV is a positive integer, meaning that consuming exactly VV units of ordinary metal O can smelt one unit of special metal X. When the amount of ordinary metal O is less than VV, smelting cannot continue.

Now you are given NN smelting records. Each record contains two integers AA and BB, meaning that AA units of ordinary metal O were put in, and finally BB units of special metal X were produced. Each record is independent, which means any ordinary metal O left over from the previous record will not be carried over to the next smelting.

Based on these NN smelting records, please infer the minimum and maximum possible values of the conversion rate VV. It is guaranteed that the testdata always has at least one solution.

Input Format

The first line contains an integer NN, representing the number of smelting records.

Then follow NN lines, each containing two integers A,BA, B, with the meaning described above.

Output Format

Output two integers, representing the minimum and maximum possible values of VV, separated by a space.

3
75 3
53 2
59 2
20 25

Hint

Sample Explanation

When V=20V = 20, we have: $\left\lfloor\frac{75}{20}\right\rfloor=3,\left\lfloor\frac{53}{20}\right\rfloor=2,\left\lfloor\frac{59}{20}\right\rfloor=2$, which satisfies all smelting records.

When V=25V = 25, we have: $\left\lfloor\frac{75}{25}\right\rfloor=3,\left\lfloor\frac{53}{25}\right\rfloor=2,\left\lfloor\frac{59}{25}\right\rfloor=2$, which also satisfies all smelting records.

And we can no longer find a valid VV that is smaller than 2020 or larger than 2525.

Constraints

For 30%30\% of the test cases, 1N1021 \leq N \leq 10^{2}.

For 60%60\% of the test cases, 1N1031 \leq N \leq 10^{3}.

For 100%100\% of the test cases, 1N1041 \leq N \leq 10^{4}, 1BA1091 \leq B \leq A \leq 10^{9}.

Lanqiao Cup 2023 Provincial Contest B Group, Problem C.

Translated by ChatGPT 5