luogu#P10074. [GDKOI2024 普及组] 刷野 III
[GDKOI2024 普及组] 刷野 III
Problem Description
Zayin is a wizard who fights monsters. This time he will face monsters standing in a line, where the HP of the -th monster is .
However, for some mysterious reason, Zayin cannot control which monster he hits. More specifically, there is a permutation of length . When Zayin attacks the -th monster, he is actually attacking the -th monster.
Each time, Zayin may choose an integer , causing the HP of the -th monster to decrease by . When a monster's HP becomes less than or equal to , that monster dies.
However, Zayin does not know what the permutation is, and he also cannot see the exact remaining HP of each monster. He can only know whether the monster dies after each attack.
Now Zayin wants to know: if he uses the best strategy, in the worst case, how many attacks are needed at most to kill monsters.
Input Format
The first line contains two positive integers , where is the number of monsters and is the number of monsters Zayin needs to kill.
The second line contains non-negative integers , where is the HP of the -th monster.
Output Format
Output one integer, the minimum number of attacks.
2 1
10 15
15
2 1
10 30
20
Hint
Sample Explanation
In the first sample, Zayin will keep attacking one monster until it dies.
In the second sample, Zayin first attacks one monster times. If it does not die, then it means he is attacking the monster with HP. At this point, Zayin will choose to attack the second monster. After attacking it times, the other monster must die, so in the worst case attacks are needed.
Constraints
For of the testdata, .
For another of the testdata, all are equal.
For another of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5