#Q10. 「一本通 1.1 练习 5」钓鱼
「一本通 1.1 练习 5」钓鱼
Description
On a horizontal roadside, there are fishing lakes, numbered from left to right as . Jiajia has hours of free time and hopes to catch as many fish as possible during this time. Starting from lake , he moves to the right, choosing to spend some time (in multiples of minutes) fishing at certain lakes. He ends his fishing trip at one of the lakes. It takes Jiajia minutes to walk from the -th lake to the -th lake. It is also measured that at the -th lake, the first minutes of fishing yields fish, and for every subsequent minutes, the number of fish caught decreases by . If the decreased number becomes negative, it is set to . 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 , the number of lakes.
The second line contains an integer , Jiajia's free time.
The third line contains integers, representing the number of fish caught in the first minutes at each lake.
The fourth line contains integers, representing the decrease in the number of fish caught every subsequent minutes at each lake.
The fifth line contains integers, where indicates the time taken to walk from the -th lake to the -th lake, which is minutes.
Output Format
Output a single line with the maximum number of fish Jiajia can catch.
Sample 1
At the st lake, fish for minutes, catching a total of fish;
At the nd lake, fish for minutes, catching a total of fish;
At the rd lake, fish for minutes, catching a total of fish;
Moving from the st lake to the nd lake and then to the rd lake takes minutes in total. The total catch is fish, which is the maximum possible.
3
1
4 5 6
1 2 1
1 2
35
Data Range and Hints
For of the data, .