ARRAYSUB - subarrays
Given an array and an integer k, find the maximum for each and every contiguous subarray of size k.
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)
print the output array
Input: 9 1 2 3 1 4 5 2 3 6 3 Output: 3 3 4 5 5 5 6
Got accepted using SQRT Decomposition!
python users segment tree tle ,use deque or dp .. i optimised to core for segment tree still tle
even brute force got accepted!!
That's weird, I considered a brute force approach and I got AC on my first attempt.
Way of solving !!
Solved with C++ using:
solved it with vectors it took 0.54s
using priority_queue, 0.02 sec
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 .)
why deque is taking so much time ie.. 0.51 seconds...