#P6510. 奶牛排队
奶牛排队
Description
Under Aunt Xiong’s lead, the cows form a straight line.
Obviously, different cows may have different heights.
Now the cows want to know: if we pick some consecutive cows, requiring that the leftmost cow is the shortest, the rightmost cow is the tallest, and cow is taller than cow . If there are cows in the middle, then their heights must not be the same as cows or . What is the maximum number of cows that can be chosen?
The cows’ heights are given from left to right. Please output the maximum number of cows that satisfies the conditions (the answer may be or , but will not be ).
Input Format
The first line contains a positive integer , the number of cows.
The next lines each contain a positive integer, where from top to bottom they give the heights of the cows from left to right.
Output Format
Output one integer in a single line, the maximum number of cows.
5
1
2
3
4
1
4
Hint
Sample Explanation
Choose cows from the st to the th; this satisfies the conditions and is the maximum.
Constraints
For all testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号