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
yaseenmollik:
20190420 19:59:28
Got accepted using SQRT Decomposition! 

aj_254:
20190403 19:08:27
python users segment tree tle ,use deque or dp .. i optimised to core for segment tree still tle 

starc_208:
20190201 17:55:53
even brute force got accepted!! 

marethyu1:
20190101 20:49:23
That's weird, I considered a brute force approach and I got AC on my first attempt. 

jmr99:
20181013 15:06:14
Way of solving !!


phoemur:
20180919 02:12:22
Solved with C++ using:


dia_aj0011:
20180917 14:45:36
solved it with vectors it took 0.54s 

dewa251202:
20180809 08:52:30
using priority_queue, 0.02 sec


surbhikohli:
20180723 09:25:54
Can the array elements in the input be either space or line separated.(I found some test cases on spoj toolkit where inputted array elements are line separated but here in problem description,array elements in input are space separated .) 

rv111:
20180715 19:00:45
why deque is taking so much time ie.. 0.51 seconds...

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 