#P10730. [NOISG 2023 Qualification] Burgers

[NOISG 2023 Qualification] Burgers

Problem Description

Lobster Kai runs a burger shop. Making one burger requires nn kinds of ingredients, and for the ii-th ingredient he has xix_i portions.

He has two burger recipes. For the ii-th ingredient, these two recipes require aia_i portions and bib_i portions respectively.

Compute the maximum number of burgers Kai can make with these ingredients.

Input Format

The first line contains a positive integer nn.

The second line contains nn integers, representing xx.

The third line contains nn integers, representing aa.

The fourth line contains nn integers, representing bb.

Output Format

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

3
14 10 100
3 1 1
2 3 1
5
2
83 72
1 3
1 3
24

Hint

Sample #1 Explanation

Kai can make 33 burgers of the first type and 22 burgers of the second type.

Sample #2 Explanation

Kai can make 2424 burgers of the first type, or 2424 burgers of the second type.

Constraints

Subtask\text{Subtask} Score Special Property
00 Samples
11 99 For all 1in1 \le i \le n, ai=bia_i=b_i.
22 1717 n,xi100n,x_i\le100.
33 2525 n,xi1500n,x_i\le1500.
44 4949 None.

For 100%100\% of the testdata, 1n1000001 \le n \le 100000, 1xi,ai,bi1091 \le x_i,a_i,b_i \le 10^9.

Translated by ChatGPT 5