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
code_aim:
20170701 19:48:26
0.01s 

iceelement:
20170630 10:33:22
AC in one, using dp and deque 

mangalnimish:
20170629 13:19:39
Wrong answer on judge 5..Please help 

itachi_2016:
20170623 21:56:07
Used segtree and got AC but 0.07s not nice though 

sagnik_66:
20170601 12:47:55
Interesting problem... 1st used Brute Force, Then used DP in O(n)! 

arvind002:
20170531 22:18:54
Try using Deque.


ashu121:
20170324 22:04:28
ac in one go


rohit9934:
20170308 15:54:05
Brute Force worked, i wasnt expecting that because time complexity was O((nk)*k).Accepted appeared like Magic. 

nilabja16180:
20170301 19:06:47
Great application of Deque!


vladimira:
20170227 20:38:14
When k<= 3 brute force is faster, this optimization speed up my solution at 15%. About NZEC in python. Read input in such way: >>>words = sys.stdin.read().split() >>>n=int(words[0]) >>>k=int(words[1]) >>>lst=map(int,words[1:n+1]) 
Added by:  priyamehtanit 
Date:  20120209 
Time limit:  0.222s0.972s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  own 