Submit | All submissions | Best solutions | Back to list |
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
|
||||||||||||||
2015-09-16 09:10:37 Ravi Chandra
Got 0.86s on first sub.After some optimizations its 0.02s |
||||||||||||||
2015-09-09 00:00:27
F***ing Brute force accepted ! |
||||||||||||||
2015-08-30 15:18:11 Harsh Vardhan Ladha
used Deque and sliding window concept.. AC in one go. O(n) Last edit: 2015-08-30 15:18:34 |
||||||||||||||
2015-08-24 18:35:03
Better do with Sliding Window instead of Segment Trees to learn something |
||||||||||||||
2015-08-20 09:35:51 kamran siddique
so simple ... |
||||||||||||||
2015-08-18 15:18:50
brute force with optimizations work good!!! |
||||||||||||||
2015-08-16 19:55:42
i keep getting NZEC for python solution. works otherwise. please tell me any spaces in the input. |
||||||||||||||
2015-08-16 13:32:58 Anmol Varshney
My 100th :D |
||||||||||||||
2015-07-25 15:11:57 abhijeet
O ((n+k )log k) |
||||||||||||||
2015-07-17 16:52:15 xxbloodysantaxx
Sliding Window , Dont waste time trying to brute force! Even if it works you miss something!! Even Segment Tree will work! Even Sparse Table works! Even Bit will work!! But this problem teaches the nice Sliding Window algorithm!! |