题目描述
Problem Background
The famous [Data Deleted] is an avid traveler! On this day, he arrived in the mysterious ZYL country.
At the customs, he was asked a question. If he answered correctly, he could smoothly reach the capital ZY of ZYL! As the renowned [Data Deleted], he actually took $10^{-233}$ seconds to figure out the solution, which was quite challenging! Therefore, he decided to test you with it.
Problem Description
Given a sequence \(a\) of length \(n\), where \(a_i\) are positive integers. You need to choose a position \(i\) and modify \(a_i\) to an arbitrary integer. Your goal is to maximize the length of the longest strictly increasing substring.
A strictly increasing substring is a contiguous subsequence of the sequence where each number is greater than the previous one (and cannot be equal or less).
For example, in the sequence \([1, 4, 2, 3, 5]\), the subsequence \([2, 3, 5]\) is a strictly increasing substring, while \([4, 2, 3]\) (not increasing) and \([1, 2, 3]\) (not continuous) are not.
Input Format
The first line contains a positive integer \(n\), representing the length of the sequence.
The second line contains \(n\) positive integers \(a_1, a_2, \ldots, a_n\), representing the sequence \(a\).
Output Format
Output a single integer, which is the maximum length of the longest strictly increasing substring after modification.
Sample Input and Output
Sample Input #1
5
1 4 2 2 3
Sample Output #1
3
Sample Input #2
5
1 2 3 2 1
Sample Output #2
4
Sample Input #3
5
1 2 3 1 5
Sample Output #3
5
Sample Input #4
6
8 2 3 1 4 5
Sample Output #4
4
Sample Input #5
6
7 2 9 4 5 6
Sample Output #5
5
Notes
[Sample Explanation #1]
For Sample #1, we can modify the third position in the sequence \([1, 4, 2, 2, 3]\) to \(5\), resulting in the new sequence \([1, 4, 5, 2, 3]\). The longest strictly increasing substring in this sequence is \([1, 4, 5]\), with a length of \(3\).
It is easy to prove that no modification scheme exists that can result in a longest strictly increasing substring longer than \(3\).
[Sample Explanation #4]
For Sample #4, we can modify the third position in the sequence \([8, 2, 3, 1, 4, 5]\) to \(0\), resulting in the new sequence \([8, 2, 0, 1, 4, 5]\). The longest strictly increasing substring in this sequence is \([0, 1, 4, 5]\), with a length of \(4\).
It is easy to prove that no modification scheme exists that can result in a longest strictly increasing substring longer than \(4\).
[Data Range]
For the first \(20\%\) of the data, \(n \le 5\) and \(a_i \le 5\).
For the first \(40\%\) of the data, \(n \le 10\) and \(a_i \le 10\).
For the first \(70\%\) of the data, \(n \le 300\).
For \(100\%\) of the data, \(1 \le n \le 10^6\) and \(1 \le a_i \le 10^9\).
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分