P10730 [NOISG 2023 Qualification] Burgers

Description

Lobster Kai runs a burger shop. Making one burger requires $n$ kinds of ingredients, and for the $i$-th ingredient he has $x_i$ portions. He has two burger recipes. For the $i$-th ingredient, these two recipes require $a_i$ portions and $b_i$ portions respectively. Compute the maximum number of burgers Kai can make with these ingredients.

Input Format

The first line contains a positive integer $n$. The second line contains $n$ integers, representing $x$. The third line contains $n$ integers, representing $a$. The fourth line contains $n$ integers, representing $b$.

Output Format

Output one integer per line, representing the maximum number of burgers that can be made.

Explanation/Hint

### Sample #1 Explanation Kai can make $3$ burgers of the first type and $2$ burgers of the second type. ### Sample #2 Explanation Kai can make $24$ burgers of the first type, or $24$ burgers of the second type. ### Constraints |$\text{Subtask}$|Score|Special Property| |:-:|:-:|:-:| |$0$|$0$|Samples| |$1$|$9$|For all $1 \le i \le n$, $a_i=b_i$.| |$2$|$17$|$n,x_i\le100$.| |$3$|$25$|$n,x_i\le1500$.| |$4$|$49$|None.| For $100\%$ of the testdata, $1 \le n \le 100000$, $1 \le x_i,a_i,b_i \le 10^9$. Translated by ChatGPT 5