Back when
was young, he enjoyed playing with sequences of numbers but there was always one problem that he could never solve. Now that he's older and has friends like you, he would like you to solve it for him.Given an array
Since
Constraints
Subtask 1 [15%]
Subtask 2 [85%]
No additional constraints.
Input Specification
The first line will contain
The second line will contain
The next i x
, stating that
Output Specification
Output
Sample Input 1
4 3
1 2 3 4
1 2
2 1
1 1
Sample Output 1
4
4
3
4
Explanation 1
In the original array, the longest non-decreasing subarray is 1 2 3 4
.
After the first update, the array is now 2 2 3 4
, and the longest non-decreasing subarray is 2 2 3 4
.
After the second update, the array is now 2 1 3 4
, and the longest non-decreasing subarray is 1 3 4
.
After the third update, the array is now 1 1 3 4
, and the longest non-decreasing subarray is 1 1 3 4
.
Sample Input 2
9 3
1 2 3 4 0 1 2 3 4
5 -1
6 5
5 5
Sample Output 2
5
5
4
6
Explanation 2
In the original array, the longest non-decreasing subarray is 0 1 2 3 4
.
After the first update, the array is now 1 2 3 4 -1 1 2 3 4
, and the longest non-decreasing subarray is -1 1 2 3 4
.
After the second update, the array is now 1 2 3 4 -1 5 2 3 4
, and the longest non-decreasing subarray is 1 2 3 4
.
After the third update, the array is now 1 2 3 4 5 5 2 3 4
, and the longest non-decreasing subarray is 1 2 3 4 5 5
.
Comments