Input
The input consists of two lines. The first line contains two integers n and k which are the lengths of the array and the sliding window. There are n integers in the second line.
Output
There are two lines in the output. The first line gives the minimum values in the window at each position, from left to right, respectively. The second line gives the maximum values.
Sample Input
8 3
1 3 -1 -3 5 3 6 7
Sample Output
-1 -3 -3 -3 3 3
3 3 5 5 6 7
設給定n 個變量1 x , 2 x ,…, n x 。將這些變量依序作底和各層冪,可得n重冪如下
n x
x x x
3
2
1
這里將上述n 重冪看作是不確定的,當在其中加入適當?shù)睦ㄌ柡螅拍艹蔀橐粋€確定的
n 重冪。不同的加括號方式導致不同的n 重冪。例如,當n=4 時,全部4重冪有5個。
給定n個整數(shù)a , a , ,an 1 2 組成的序列。序列中元素i a 的符號定義為:
ï î
ï í
ì
- <
=
>
=
1 0
0 0
1 0
sgn( )
i
i
i
i
a
a
a
a
符號平衡問題要求給定序列的最長符號平衡段的長度L,即:
þ ý ü
î í ì
= + - = å
=
£ £ £
max 1| sgn( ) 0
1
j
k i
i j n k
L j i a 。
例如,當n=10,相應序列為:1,1,-1,-2,0,1,3,-1,2,-1 時,L=9。