시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 0 0 0 0.000%

## 문제

Byteasar studies computer science at the University of Bytetown. There is a snack vending machine at his faculty that sells n types of snacks, numbered 1 through n. Snacks of different types may have different price, since they differ in size and flavor.

Recently Byteasar discovered that the vending machine is broken. If one buys a snack of type i, the vending machine additionally dispenses one snack of each of the types 1, 2, . . . , i − 1, provided that snacks of these types are available (if there are no snacks of some of the types 1, 2, . . . , i − 1, simply no snack of this type is dispensed). Buing snack of type i is possible only if at least one snack of this type is available.

Byteasar decided to take advantage of the fault he discovered. He would like to find out what is the maximum total value (that is, the sum of prices) of snacks that he can obtain in the vending machine using a given amount of money. He does not have to use all the money.

## 입력

The first line of input contains two integers n and k (1 ≤ n ≤ 40, 1 ≤ k ≤ 64 000): the number of types of snacks and the amount of money that Byteasar has at his disposal. The second line holds n integers c1, ..., cn (1 ≤ i ≤ 40), the prices of snacks of respective types. The third line holds n integers l1, ..., ln (0 ≤ li ≤ 40), the quantities of snacks of respective types that are available in the vending machine.

## 출력

The only line of output should contain one integer: the total price of snacks that Byteasar can obtain in the vending machine using at most k units of money.

## 예제 입력 1

6 8
7 2 3 5 7 2
1 3 0 3 2 1


## 예제 출력 1

30


## 힌트

Byteasar buys a snack of type 6. The vending machine dispenses one snack of each of the types 1, 2, 4, 5 and 6. Next, Byteasar buys a snack of type 4. In addition to this snack, the vending machine dispenses one snack of type 2.