ARRAYSUB - subarrays

Given an array and an integer k, find the maximum for each and every contiguous subarray of size k.

Input

the number n denoting number of elements in the array then after a new line we have the numbers of the array and then k in a new line

n < 10^6
k < 10^5
1 <= k <= n

and each element of the array is between 0 and 10^6

(Edited: In fact, n <= 10^5)

Output

print the output array

Example

Input:
9
1 2 3 1 4 5 2 3 6
3

Output:
3 3 4 5 5 5 6

Added by:priyamehtanit
Date:2012-02-09
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:own

hide comments
2012-02-15 22:02:00 Garima Sachan
Few test cases :
7
1 2 8 4 5 2 3
3
8 8 8 5 5

7
1 2 8 4 5 2 3
4
8 8 8 5

Last edit: 2012-02-16 04:13:03
2012-02-15 15:48:54 pankaj khandelwal
please any one tell me is there any ambiguity with space in input or output. if yes then please make it clear to me.
thanks :)
2012-02-15 05:07:18 I_AM
Good, Tricky but short question.. I appreciate your work sister..Keep it up..
HINTS: The concept of my soln. to this question is a bit similar to the question HOTELS.

Last edit: 2012-02-15 09:16:29
2012-02-13 11:20:07 Shashank_Jain
Priyanit-nice question :-)
2012-02-12 20:34:04 Aradhya
@secret:not needed..I totally agree with maaz!!but very tough question..took my 3 nights...njoyd this 1..good work..priyamehtanit

2012-02-12 14:18:01 MR. BEAN
take care of spaces , costed me 4 WA :(
2012-02-12 14:05:31 Zhiang
not leaving spaces costed me so many WA :(
2012-02-12 09:44:16 BOND
nice one... tricky though :)
2012-02-11 16:45:03 ! include(L.ppt)
does the output contains any space between the elements.....????
2012-02-11 05:20:37 hibernating
stuck up in tle :(
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.