#P7287. 「EZEC-5」魔法
「EZEC-5」魔法
Problem Description
Xiao Ming is a magician.
He has a sequence that can be enchanted.
He has two kinds of magic:
- Spend mana, choose an interval in , and add to all of .
- Spend mana, choose an interval in , and multiply all of by .
Now Xiao Ming wants to cast magic on the sequence several times so that there exists a sub-interval whose element sum is at least . Please output the minimum mana cost that Xiao Ming needs to spend.
Input Format
The first line contains four integers , representing the sequence length, the costs of the two kinds of magic, and the required sum.
The next line contains integers, representing the initial sequence.
Output Format
One integer, representing the minimum cost.
5 2 3 102
-3 -1 1 -2 0
17
Hint
[This problem uses bundled testdata.]
For of the testdata, , .
For another of the testdata, .
For another of the testdata, .
For another of the testdata, .
For of the testdata, , , , .
[Sample Explanation]:
For the sample, one of the best methods is to use Magic 1 once to change (1,4), use Magic 1 three times to change (2,5), and use Magic 2 three times to change (2,5).
-3 -1 1 -2 0
-2 0 2 -1 0
-2 1 3 0 1
-2 2 4 1 2
-2 3 5 2 3
-2 6 10 4 6
-2 12 20 8 12
-2 24 40 16 24
-2+24+40+16+24 >= 102
Translated by ChatGPT 5