#Q10. 「一本通 1.1 练习 5」钓鱼

「一本通 1.1 练习 5」钓鱼

Description

On a horizontal roadside, there are nn fishing lakes, numbered from left to right as 1,2,,n1,2,…,n. Jiajia has HH hours of free time and hopes to catch as many fish as possible during this time. Starting from lake 11, he moves to the right, choosing to spend some time (in multiples of 55 minutes) fishing at certain lakes. He ends his fishing trip at one of the lakes. It takes Jiajia 5×Ti5\times T_i minutes to walk from the ii-th lake to the (i+1)(i+1)-th lake. It is also measured that at the ii-th lake, the first 55 minutes of fishing yields FiF_i fish, and for every subsequent 55 minutes, the number of fish caught decreases by DiD_i. If the decreased number becomes negative, it is set to 00. To simplify the problem, Jiajia assumes no one else is fishing and no other factors affect his expected catch. Write a program to determine the maximum number of fish Jiajia can catch.

Input Format

The first line contains an integer nn, the number of lakes.

The second line contains an integer HH, Jiajia's free time.

The third line contains nn integers, representing the number of fish caught in the first 55 minutes at each lake.

The fourth line contains nn integers, representing the decrease in the number of fish caught every subsequent 55 minutes at each lake.

The fifth line contains n1n-1 integers, where TiT_i indicates the time taken to walk from the ii-th lake to the (i+1)(i+1)-th lake, which is 5×Ti5\times T_i minutes.

Output Format

Output a single line with the maximum number of fish Jiajia can catch.

Sample 1

At the 11st lake, fish for 1515 minutes, catching a total of 4+3+2=94+3+2=9 fish;

At the 22nd lake, fish for 1010 minutes, catching a total of 5+3=85+3=8 fish;

At the 33rd lake, fish for 2020 minutes, catching a total of 6+5+4+3=186+5+4+3=18 fish;

Moving from the 11st lake to the 22nd lake and then to the 33rd lake takes 1515 minutes in total. The total catch is 3535 fish, which is the maximum possible.

3
1
4 5 6
1 2 1
1 2

35

Data Range and Hints

For 100%100\% of the data, 2n100,1H202\le n\le 100, 1\le H\le 20.