#P5653. 基础最优化练习题
基础最优化练习题
Description
YSGH has a number with initial value . For the next minutes, each minute YSGH can add an integer to , where . At the same time, YSGH must ensure that at the end of the -th minute, .
Let be the value of at the end of the -th minute. Now YSGH gives you a sequence of numbers. You need to maximize .
You only need to output the maximum value.
Input Format
The first line contains two positive integers , with the same meaning as in the statement.
The second line contains integers, where the -th integer is , with the same meaning as in the statement.
The third line contains integers, where the -th integer is , with the same meaning as in the statement.
It is guaranteed that the input ensures there exists at least one sequence that satisfies the conditions.
Output Format
The first line contains one integer, which is the answer.
5 1
4 3 2 3 2
5 7 -5 9 -10
24
Hint
For of the data, , .
For of the data, .
For of the data, .
For of the data, .
There is another of the data where .
For of the data, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号