CT57582

Bhanu's marks Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Bhanu found an old ledger of marks in the print shop attic at the ember dunes of Ashfall. The margin notes pose a precise question. 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: 1021 786 -481038833 -929962628 336774675 800196547 797110261 210759066 474739485 -75567787 -923527141 -655082429 -81754432 114533740 -318720196 167366251 -172072608 863772058 -195846535 747591025 -67596222 -879599285 46525941 194994712 320925948 -29412046 -284893976 994130790 976858183 -212148139 -604394523 -621803972 350290928 875858045 -88288720 526281872 994902741 -843100814 -554123936 760557637 -399944219 -912417519 274476437 50545686 80879893 677046438 -435143243 1676516 363077632 386577191 -864217297 553082603 351851506 -710789151 -451414158 -347600644 935690455 -106818376 190908981 -90739607 -661086442 -185317691 -332453919 -992664879 332188449 -877857803 308769741 -11399240 -314783629 -10997178 348607089 -810575865 -104758044 208268625 -524018188 856394550 29927816 -644652307 13796…
Output: 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 994902741 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 991114234 …

Example 2:

Input: 1712 193 61533687 528492618 986177287 -258588145 503871314 704301256 411433814 480170754 -931614372 898637875 618460204 -734367502 -83625377 123713391 732977947 -386545737 -70665814 226994840 53347977 -919494851 917727010 -52630134 -45039928 -812315671 -690907986 -169255109 -310327965 966904229 -835799675 -466547292 -918453601 231013334 -559167480 -157251597 -821792901 -623884631 -540857458 185513719 -505476515 943172427 -65575340 160876975 -123877695 -351877303 454288457 -572724583 970113205 -875571870 746606358 -317785758 -667794785 -936318857 617703202 -63922166 -156475186 538807628 888346140 -288239382 -131008576 -395751960 124854921 636037606 186561837 621290139 295069108 -515154653 -347213923 988712351 -250933303 865352476 312557773 765919266 -668974681 703196073 438535971 -747397197…
Output: 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 988712351 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 991275815 …

Example 3:

Input: 3338 952 -131613996 976495562 -38313209 719227409 559949814 -849429672 -596696775 888020001 -640677628 -366399983 -690599497 907492903 945931077 47464046 689681722 798519479 960969620 706244116 -998525876 -580932659 797990899 454084027 -33836343 296038260 258584240 -952209187 -289509493 701190346 716061875 900694164 485489736 -491320274 -754232111 411865943 992037933 129634823 626474444 728648309 147296409 930527905 -983322558 -589672095 585659636 -727019305 -914961882 66753405 -107025464 -854281600 830894138 112232252 -656754090 -185169401 -802427093 -200775073 39035523 -824576215 -140288317 -118060728 862358226 570322660 825068508 -468773019 -258989190 -997366091 -277644076 59894315 469539401 160935874 -258735623 -96197115 -477753334 618708760 -501583757 -419892539 -925702670 840575057 3…
Output: 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 999318888 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Bhanu's marks Peak per Window - MEDIUM Coding Problem | CodeTikki