Sphere Online Judge

Because of maintenance, it is currently impossible to submit any solutions. The maintenance will end around 3:00 am GMT (4:00 am SPOJ time).

This message will disappear once the maintenance is finished.

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.


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



1 <= k <=n

and each element of the array is between 0 and 10^6


print the output array


1  2  3  1  4  5  2  3  6
3 3 4 5 5 5 6

Added by:priyamehtanit
Time limit:1s-4s
Source limit:50000B
Memory limit:256MB
Cluster: Pyramid (Intel Pentium III 733 MHz)

hide comments
2014-12-14 19:32:01 Ayushi Srivastava
hey i am getting wa for the following code:
but it is covering the test cases :( wat to do??? plz see

Last edit: 2014-12-14 19:40:17
2014-11-17 15:50:17 Siya
My first problem with segment trees
Ac in one go :) :)
2014-11-13 19:39:06 Aravind
0.75(time) with seg trees

Last edit: 2014-11-13 19:39:32
2014-11-10 08:00:55 pankaj kumar
got AC in first attempt...
2014-10-23 23:28:18 Rajat (1307086)
F**k. Ans has spaces. This gave me several wrong answers.
2014-10-23 23:28:02 Rajat (1307086)
F**k. Ans has spaces. This gave me several wrong answers.
2014-10-14 17:57:52 Vikas
Did it in O(N) time :D
2014-10-12 16:00:00 xlytron
There are spaces in the output.
2014-10-11 19:35:27 jack sparrow
hash+heap+twopointer=AC :D
2014-10-05 15:02:34 Ayush Vatsa
my brute force +deque solution both got AC'd in 0.2sec.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.