#P3287. [SCOI2014] 方伯伯的玉米田
[SCOI2014] 方伯伯的玉米田
Description
While walking along the edge of his farmland, Uncle Fang suddenly noticed that one row of corn looked very unattractive. There are stalks in this row, and their heights vary. Uncle Fang thinks a non-decreasing sequence is beautiful, so he decides to first raise some stalks and then pull out any stalks that spoil the beauty, so that the heights of the remaining stalks form a non-decreasing sequence. He may choose an interval and increase every stalk in that interval by 1 unit of height; he may perform at most such operations. He may also freely choose any set of stalks to remove. What is the maximum number of stalks that can remain to form a beautiful row?
Input Format
The first line contains two integers , , denoting the number of stalks in this row and the maximum number of operations allowed, respectively. The second line contains integers; the -th number is the height of the -th stalk from left to right.
Output Format
Output a single integer, the maximum number of remaining stalks.
3 1
2 1 3
3
Hint
Constraints: of the testdata satisfies: , , .
Translated by ChatGPT 5
京公网安备 11011102002149号