CT41477

The Selene Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the moonlit lagoon of Selene with crates of signals, and Sailor the registry keeper must account for every last one. Task: For every contiguous window of length k, print the maximum. Input format: First line: n and k. Second line: n integers. Output format: Print n-k+1 maxima space-separated. Constraints: 1 <= k <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 24 18 -16707496 -577569977 811997215 1337885 304605316 -936295941 531473968 728010939 -273628780 -643616983 -949188045 -426000706 112029985 -503990710 942367588 46374085 122706342 -740845957 -284250910 -76856914 -648404384 -259898747 -33949888 -199523193
Output: 942367588 942367588 942367588 942367588 942367588 942367588 942367588

Example 2:

Input: 3506 3113 301509231 821572614 668296457 -71227554 646057993 -85073366 -911480964 835689926 216894772 -102407014 -857855840 -315663381 924194436 830516090 282989733 -557959728 849832161 -831861735 900525911 576207655 300348812 531409999 500829416 558206323 -989949441 -965265858 767281805 -658612692 879230240 386434981 -332712823 -698056895 135591121 -428922560 92663171 -211313806 -156435280 -137103285 232386874 527044086 554841049 -398642237 433118835 -363637759 -572995879 284979346 947771770 -711377309 223034701 972851964 278609436 -17593052 796885130 776449108 -746339966 298110354 -943959047 -710060688 871948592 -779644493 -573745586 829790650 -253049777 667222834 959348337 -284562962 -376714258 -953021815 46386230 -957755467 267023788 954453417 -853709082 -714950231 65501660 944296319 49…
Output: 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 999599053 …

Example 3:

Input: 2462 163 -28506404 903817036 -891657199 422839696 61305808 -538480145 853014502 887165363 907233288 -774669384 -104455191 265801033 553731647 939671622 623957516 -974884445 464109101 -760455627 -698587024 105491731 -816256387 -37947675 110437404 334384584 409668532 952004565 -798132002 932745440 639423970 176580480 546194379 146831481 781616231 -732727977 373359007 -533663284 -250693915 147683821 98657877 -607546767 -954327541 -713619130 -596823210 -485458565 -174187569 463360523 -337309874 500335915 999974207 949095327 997130130 507612755 -669602810 877959420 928665810 -19760545 -306237562 -396462723 997104865 -860968759 610047383 -975754795 46044320 -55560692 99064949 390488817 -966087263 -659454793 -488940545 -136743119 -150880017 -155440745 170444860 999046905 614967291 585826997 29144…
Output: 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999974207 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 999046905 994576794 994576794 994576794 994576794 994576794 994576794 …

Constraints:

1 <= k <= n <= 4000; -10^9 <= a[i] <= 10^9.

Loading...
Test Cases:No test cases
No test cases available.
The Selene Peak per Window - MEDIUM Coding Problem | CodeTikki