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-05-28 04:59:55 diablo
same here! all test here cases work but gives wrong answer in the fifth one
2012-05-24 12:39:03 Abhishek Sharma
My program works for every test cases(in question and posted in comments) ;But i am getting WA. Can anyone provide me some more critical test cases ..??
2012-04-21 08:30:46 coading
i m using 2 for loops for sorting & it showing "TLE" any suggestions.....
2012-04-08 00:28:11 Anand
6

1 2 4 5 2 1
3
I am able to get correct answer for it. but still the fifth test case fails!!!
2012-04-02 06:45:43 ramaravind
@ram:check for the following test case
6

1 2 4 5 2 1
3

Last edit: 2012-04-02 06:46:06
2012-04-01 10:46:39 ram
am getting WA in the fifth test case :( where exactly be the spaces ..
2012-03-29 12:01:46 ♘Prabhat


Last edit: 2014-03-24 17:10:41
2012-03-05 12:52:06 aragon
Yes,there are spaces in the output.
2012-02-27 23:09:58 mynameborat
are there spaces in the o/p?
2012-02-24 10:43:18 Rishi Mukherje
I think there is some problem...I am getting NZEC with python..please tell me about the spaces in the input...or output..
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.