#P8776. [蓝桥杯 2022 省 A] 最长不下降子序列
[蓝桥杯 2022 省 A] 最长不下降子序列
Problem Description
Given an integer sequence of length : . You now have one chance to modify consecutive numbers in it to any same value. Please compute how to modify it so that the longest non-decreasing subsequence of the modified sequence is as long as possible, and output this maximum length.
A longest non-decreasing subsequence means a subsequence of the sequence, where each number in the subsequence is not less than the number before it.
Input Format
The first line contains two integers and .
The second line contains integers .
Output Format
Output one line containing one integer, representing the answer.
5 1
1 4 2 8 5
4
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
For all testdata, , .
Lanqiao Cup 2022 Provincial Contest, Group A, Problem G.
Translated by ChatGPT 5