#P7129. 「RdOI R1」冰淇淋游戏(play)
「RdOI R1」冰淇淋游戏(play)
Description
Little T found that a new game has appeared on the market recently. This game has levels. Playing level once costs stamina, and you can play level at most times. To play level , you must have played level at least once. Of course, playing level does not require this prerequisite.
The rules are as follows (for level ):
There are ice creams in a row. The deliciousness of the -th ice cream is . Each time you need to choose one ice cream to eat, for a total of times. On the -th time, if you eat the -th ice cream, you gain points.
Of course, eating ice cream is not that easy. On the first time, you must eat the specified -th ice cream. After that, each time you can only eat an ice cream at either end of the already eaten segment. For example, if you first eat the -nd ice cream, then the second time you can eat the -st or the -rd one (if it exists).
Since Little T is not good enough at computing these complicated scores, he wants to ask for your help. Under the condition that the stamina used does not exceed , what is the maximum score he can obtain?
Input Format
The first line contains two integers , representing the number of levels and the amount of stamina.
The next lines from line to line describe the levels. For level , line and line describe level .
Line contains four integers , as described in the statement.
Line contains integers. The -th integer is , as described in the statement.
Output Format
Output one integer in a single line: the maximum score obtainable with stamina used not exceeding .
2 20
9 1 4 2
3 2 4 1
11 2 4 3
2 3 2 2
48
3 20
9 2 1 1
10000
1 4 1 1
1
1 4 1 1
2
20003
Hint
[Sample Explanation]
Sample 1:
The optimal solution is to play level 1 once and then play level 2 once.
In level 1, eat the ice creams in the order of the -st. You can get $2\times 1+4\times 2+1\times 3+3\times 4=2+8+3+12=25$ points.
In level 2, eat the ice creams in the order of the -st. You can get points.
So the maximum total score is .
Sample 2:
The optimal solution is to play level 1 twice, level 2 once, and level 3 once.
You can get points.
[Constraints]
For of the testdata, $1 \le n \le 10 , 1 \le k_i,m_i,s_i,y_{i,j} \le 100 , 1 \le t \le 100$.
For another of the testdata, $1 \le n \le 100 , 1 \le k_i,m_i,s_i,y_{i,j} \le 100 , 1 \le t \le 10^4$.
For of the testdata, $1 \le n \le 200 , 1 \le k_i,m_i,s_i,y_{i,j} \le 500,1 \le t \le 10^5,1\le c_i\le k_i$.
[Notes / Hints]
- Try to understand the samples.
[File Input/Output] (Simulation, not required when submitting code)
- Filename:
play.cpp - Input filename:
play.in - Output filename:
play.out
Translated by ChatGPT 5
京公网安备 11011102002149号