#P2048. [NOI2010] 超级钢琴
[NOI2010] 超级钢琴
Description
Xiao Z is a well-known pianist. Recently, Dr. C gave Xiao Z a super piano, and Xiao Z hopes to use it to create the most beautiful music in the world.
This super piano can play notes, indexed from to . The beauty value of the -th note is , where can be positive or negative.
A “super chord” consists of several consecutive notes, with the number of included notes no less than and no more than . We define the beauty of a super chord as the sum of the beauty values of all notes it contains. Two super chords are considered the same if and only if the sets of notes they contain are identical.
Xiao Z decides to compose a piece consisting of super chords. To make the piece more pleasing, the super chords must be different. We define the beauty of a piece as the sum of the beauties of all its super chords. Xiao Z wants to know the maximum possible beauty of such a piece.
All testdata satisfy: , , and it is guaranteed that there exists a valid piece that meets the requirements.
Input Format
The first line contains four positive integers , where is the number of notes, is the number of super chords in the piece, and and are the lower and upper bounds on the number of notes a super chord can contain, respectively.
The next lines each contain an integer , representing the beauty value of each note in increasing index order.
Output Format
Output a single integer, the maximum possible beauty of the piece.
4 3 2 3
3
2
-6
8
11
Hint
Sample Explanation
There are different super chords:
- Notes , beauty .
- Notes , beauty .
- Notes , beauty .
- Notes , beauty .
- Notes , beauty .
The optimal plan is: the piece consists of chords , with total beauty .

Translated by ChatGPT 5
京公网安备 11011102002149号