Longest Loose Segment
시간 제한2초메모리 제한256 MB
여러 번의 교환을 거친 뒤, 최댓값과 최솟값의 합이 길이보다 큰 가장 긴 부분 배열의 길이를 구한다.
문제
A list is called loose if .
Today Rikka got a list of length . She wants to find the longest segment in such that list is loose.
Rikka will make turns with list . On each turn, Rikka will perform one or more given operations in sequence. Each operation is swapping two elements in list . Your task is to calculate the length of the longest loose segment of and the resulting list after each turn.
Note that the operations on turn are performed on the list that was the result of turn .
입력
The first line contains two integers and ( and ).
The second line contains integers () that constitute the initial list .
Then follow descriptions of the turns. For each turn, the first line contains a single integer (), the number of swaps. Then lines follow: each of them contains two integers and ( and ) such that Rikka will swap and in this operation.
It is guaranteed that .
출력
On the first line, output a single integer: the length of the longest loose segment of .
Then output lines. On each of them, print a single integer: the length of the longest loose segment of the resulting list after each turn.