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

hide comments
pankaj khandelwal: 2012-02-15 15:48:54

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 :)

I_AM: 2012-02-15 05:07:18

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
Shashank_Jain: 2012-02-13 11:20:07

Priyanit-nice question :-)

Aradhya: 2012-02-12 20:34:04

@secret:not needed..I totally agree with maaz!!but very tough question..took my 3 nights...njoyd this 1..good work..priyamehtanit

MR. BEAN : 2012-02-12 14:18:01

take care of spaces , costed me 4 WA :(

Zhiang: 2012-02-12 14:05:31

not leaving spaces costed me so many WA :(

BOND: 2012-02-12 09:44:16

nice one... tricky though :)

! include(L.ppt): 2012-02-11 16:45:03

does the output contains any space between the elements.....????

hibernating: 2012-02-11 05:20:37

stuck up in tle :(

Secret: 2012-02-11 05:20:37

more test cases ??


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