시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB172534239.252%

문제

Kai the lobster is starting a burger chain selling burgers. He has $n$ ingredients to work with, which are labelled from $1$ to $n$. For each ingredient $i$, he has $x[i]$ portions of ingredient $i$.

He has two recipes for burgers. For each ingredient $i$, the first recipe requires $a[i]$ portions of ingredient $i$ and the second recipe requires $b[i]$ portions of ingredients $i$.

Can you help Kai compute the maximum total number of burgers he can make?

입력

The first line of input consists of one integer $n$, the number of different ingredients.

The second line consists of $n$ spaced integers $x[1], x[2], \dots , x[n - 1], x[n]$, the total number of portions Kai has of each ingredient.

The third line consists of $n$ spaced integers $a[1], a[2], \dots , a[n - 1], a[n]$, the number of portions of each ingredient for the first recipe.

The fourth line consists of $n$ spaced integers $b[1], b[2], \dots , b[n - 1], b[n]$, the number of portions of each ingredient for the second recipe.

출력

The output should contain a single integer on a single line, the largest number of burgers Kai can make.

제한

  • $1 ≤ n ≤ 100\,000$
  • $1 ≤ x[i], a[i], b[i] ≤ 10^9$

서브태스크

번호배점제한
19

$a[i] = b[i]$ (i.e. the two recipes are the same)

217

$n, x[i] ≤ 100$

325

$n, x[i] ≤ 1500$

449

No additional restrictions

예제 입력 1

3
14 10 100
3 1 1
2 3 1

예제 출력 1

5

He can make $3$ burgers using the first recipe and $2$ burgers using the second recipe for a total of $5$ burgers.

예제 입력 2

2
83 72
1 3
1 3

예제 출력 2

24

He can make $24$ burgers of either type, since both recipes are the same.

채점 및 기타 정보

  • 예제는 채점하지 않는다.