#P15442. [蓝桥杯 2025 国研究生组] 山峰子序列
[蓝桥杯 2025 国研究生组] 山峰子序列
Background
C/C++/Python Postgraduate Group.
Problem Description
A sequence is a “mountain peak sequence” if and only if there exists an index-pair sequence of length ( can be chosen arbitrarily), , such that:
- and .
- .
- .
- and is the maximum value of sequence on the interval .
- Sequence is strictly increasing on the interval , and strictly decreasing on the interval .
Given an integer array of length , , find the longest subsequence such that is a “mountain peak sequence”, and output its length.
Note: The index-pair sequence is based on the indices of the subsequence , and the indices of start from 1.
Input Format
The first line contains a positive integer .
The second line contains integers , separated by one space.
Output Format
Output one line containing one integer, which is the answer.
10
1 3 2 4 1 2 3 4 3 1
8
Hint
Sample Explanation
You can take the subsequence . Its length is 8 and it is a “mountain peak sequence”. The index-pair sequence is .
Test Case Scale and Conventions
For of the test cases, .
For of the test cases, .
For all test cases, , .
Input Format
Output Format
Translated by ChatGPT 5