#P15532. 【MYCOI R1】好想大声说爱你
【MYCOI R1】好想大声说爱你
Description
There are children standing in a row. The height of the -th child is centimeters.
As a magician, you have two types of magic:
- "Lock": Point your wand at a child.
- "Grow": Increase the height of the **last child whom your wand is pointing to by centimeter. Note: If you have never performed "Lock" before, you cannot perform this magic.
The teacher thinks that if only one child keeps growing taller, the neighboring children might feel inferior. Therefore, the teacher requires that you may only perform the "Grow" magic if, within the children to the left (or up to the start of the line if fewer than exist) and the children to the right (or up to the end of the line if fewer than exist) of the chosen child, there is at least one child whose height is greater than or equal to the chosen child's height.
Since magic requires casting time, the teacher wants to know the minimum total number of magic actions (both "Grow" and "Lock") required to make every child’s height at least .
If it is impossible, output Che_is_Loser.
Input Format
The first line contains three positive integers , , .
The second line contains positive integers , separated by spaces.
A single positive integer representing the minimum number of operations required.
Output Format
A single positive integer representing the minimum number of operations required.
3 1 4
1 2 3
9
5 1 5
2 3 5 1 4
14
4 1 5
1 3 3 1
17
Hint
This problem uses bundled testing.
::cute-table{tuack}
| Subtask | Special Properties | Points |
|---|---|---|
| Subtask 1 | 10 | |
| Subtask 2 | 1 | |
| Subtask 3 | 20 | |
| Subtask 4 | is non-decreasing | |
| Subtask 5 | No special properties | 49 |
For of the data, it is guaranteed that , .
京公网安备 11011102002149号