PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000292. Bột phép thuật - 2 (Magic Powder - 2)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bột phép thuật - 2 (Magic Powder - 2)

Magic Powder - 2

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

One cookie requires aia_i grams of every ingredient ii. There are bib_i grams of each ingredient and kk grams of magic powder. One gram of powder can become one gram of any ingredient. Maximize the number of cookies.

Input

First line: n,kn,k. Next two lines: nn integers aia_i and nn integers bib_i, respectively.

Output

Print one integer: the maximum achievable value.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le20; 1≤k,ai,bi≤1001\le k,a_i,b_i\le100.
  • Subtask 2 (30 points): 1≤n≤1051\le n\le10^5; 1≤k,ai,bi≤1091\le k,a_i,b_i\le10^9; a1=⋯=an=1a_1=\cdots=a_n=1.
  • Subtask 3 (50 points): 1≤n≤1051\le n\le10^5; 1≤k,ai,bi≤1091\le k,a_i,b_i\le10^9.

Examples

Input 1

3 1
2 1 4
11 3 16

Output 1

4

Explanation

Four cookies require (8,4,16) grams; only one gram is missing. Five require more powder.

Input 2

1 1000000000
1
1000000000

Output 2

2000000000

Explanation

Convert all powder into the only ingredient.