MicrosoftOA #67
The Longest Spike
估计简单可在线判题
考点(AI 标注)哈希计数
Choose any numbers from the array and rearrange them into a sequence that strictly increases and then strictly decreases. The two parts share the peak, and either part may consist of just the peak, so purely increasing, purely decreasing, and single-element sequences are also valid. Return the maximum length.
This site uses a standard input/output protocol.
输入格式
The first line contains N, and the second line contains N integers. This site uses 1≤N≤200000 and elements in −10⁹..10⁹.
输出格式
Output a single integer, the answer.
样例 1
输入:
2
1 2
输出:
2
样例 2
输入:
6
2 5 3 2 4 1
输出:
6
样例 3
输入:
3
5 5 5
输出:
1
样例说明
Example 1: 1, 2 is already a peak, of length 2. Example 2: you can arrange 1, 2, 3, 4, 5, 2, of length 6. Example 3: strictness forbids repeating the peak value, so only one 5 can be used.