## NOI '10 P2 - Super Piano

View as PDF

Points: 25 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem type
##### National Olympiad in Informatics, China, 2010

Little Z is a minorly famous pianist. Recently, Doctor C has gifted him with a super piano. With it, little Z hopes to create the world's most enchanting music.

The super piano can produce different notes, numbered from to . The loveliness of the -th note is , where can be positive or negative.

A "super chord" consists of some number of numerically consecutive notes, where the chord does not contain fewer than notes, nor more than notes.

We define the loveliness of a chord as the sum of the lovelinesses of all the notes it contains. Two super chords are considered the same if and only if both their sets of notes are identical.

Little Z decides to compose a piece consisting of super chords. To make the piece more extraordinary, little Z requires the piece to also consist of different super chords. We define the loveliness of a piece as the sum of the lovelinesses of all its super chords. Little Z would like to know just how lovely the loveliest possible piece can be.

#### Input Specification

The first line contains four positive integers , , , and . represents the number of notes on the super piano. represents the number of super chords that the piece should consist of. and respectively represent the minimum and maximum number of notes that can be in a single super chord.

#### Output Specification

The output consists of a single integer, the maximum possible loveliness of a piece that little Z can compose.

#### Sample Input

4 3 2 3
3
2
-6
8

#### Sample Output

11

#### Explanation

There are possible super chords:

1. Notes to , for a total loveliness of
2. Notes to , for a total loveliness of
3. Notes to , for a total loveliness of
4. Notes to , for a total loveliness of
5. Notes to , for a total loveliness of

The loveliest composition comprises of super chords , , and for a total loveliness of .

#### Constraints

There are total test cases with bounds satisfying:

Test Case

All of the test cases satisfy and .
Furthermore, it is guaranteed that a composition fitting the requirements will exist.

Problem translated to English by Alex.