#P10072. [GDKOI2024 普及组] 刷野 I
[GDKOI2024 普及组] 刷野 I
Problem Description
Zayin is a wizard who fights monsters. This time, he will face monsters standing in a line, where the -th monster has health .
Zayin attacks first using one type of attack. After the attack, all monsters with health less than or equal to die. After each time Zayin attacks, all surviving monsters deal point of damage to Zayin. The above process repeats until Zayin kills all monsters.
Zayin has three types of attacks:
-
Normal Attack: Costs energy. Choose one monster and reduce its health by .
-
"Tianyinbo": Costs energy. Choose one monster and reduce its health by .
-
"Tianleipo": Costs energy. Reduce the health of all monsters by .
Now Zayin has energy in total. He wants to know, under the optimal strategy, the minimum amount of health he will lose to defeat the monsters.
Input Format
The first line contains two positive integers , where is the number of monsters and is the amount of energy Zayin has.
The second line contains non-negative integers , where is the health of the -th monster.
Output Format
Output one integer in one line, representing the answer.
3 4
2 4 4
6
Hint
For of the testdata, .
For another of the testdata, .
For another of the testdata, all are equal.
For of the testdata, , , .
Translated by ChatGPT 5