Sphere Online Judge

Computer geeks! Show off your skills and claim the job of your dreams! RecruitCoders.com

SPOJ Problem Set (classical)

10582. subarrays

Problem code: ARRAYSUB

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

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-4s
Source limit:50000B
Languages:All
Resource:own

hide comments
2012-05-24 14: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 10:30:46 coading
i m using 2 for loops for sorting & it showing "TLE" any suggestions.....
2012-04-08 02: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 08:45:43 ramaravind
@ram:check for the following test case
6

1 2 4 5 2 1
3

Last edit: 2012-04-02 08:46:06
2012-04-01 12:46:39 ram
am getting WA in the fifth test case :( where exactly be the spaces ..
2012-03-29 14:01:46 ℙℜαвℍα₮
@Mr.Bean thanks sir i got AC in first attempt

Last edit: 2012-05-20 14:30:27
2012-03-05 13:52:06 aragon
Yes,there are spaces in the output.
2012-02-28 00:09:58 mynameborat
are there spaces in the o/p?
2012-02-24 11:43:18 Rishi
I think there is some problem...I am getting NZEC with python..please tell me about the spaces in the input...or output..
2012-02-15 23: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 05:13:03
SPOJ System © 2012 Sphere Research Labs | Projekty informatyczne i aplikacje na zamówienie. All Rights Reserved.