CT40119

The Peak per Window Beneath Keelwind

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the shipyard of Keelwind close for winter, Farhan must finish the beacons ledger - one figure at a time. 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: 2526 1627 307307838 709996883 900467214 -187893622 131851163 -733621275 -217827166 -90889859 221552802 -441409767 -807624094 -911075813 484989608 -188959394 -975828090 -947097740 768792256 -138979924 127552328 741073780 995125309 -789532220 332803677 -760745066 -132958264 817278638 -500088668 76717144 756940148 740052302 506583494 -521748861 -152159502 -894778659 894272253 -847756840 -713383980 434345259 -473336185 -118036845 929740213 -104195374 69100567 789516644 677945748 4199258 -542878669 6031603 464129649 -927058690 5258096 614598558 550730618 188022408 -731135241 -106363129 645187953 -903725050 -490537465 833712000 892515241 -235230662 865243967 -46712186 -477802458 261145799 60771544 -687910020 954962031 414149223 501601787 -637580168 -316052016 528006059 -764615080 503953191 24672…
Output: 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 999402693 …

Example 2:

Input: 1167 1062 -213720970 801460125 797591082 -329625324 -319284112 -779015849 -941602022 458619203 -687472176 -382323668 -925895404 -468157069 436710078 -399060068 -355909156 424575897 -813964675 259264489 401253319 -626505851 744952656 -739668571 -993938274 156688850 262907875 134216608 360346497 244726366 651403753 247936425 840092492 -309906592 276161250 574351941 326262463 -667090260 -393709492 -301707859 806031656 972348272 -897533703 -336810732 -607494842 -606361788 -662519489 -449320265 959983659 812783658 527072838 -40724064 -855301764 706457853 -865913221 -500731610 -818001190 891728186 765319748 592128144 -423753471 -649774535 -572128781 -264779517 -512676063 37328702 -91467157 201967736 -907085862 -335093497 250791164 58626691 -487217308 -764641147 -654716482 435709110 -646564165 76…
Output: 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 999994287 …

Example 3:

Input: 3498 1520 599823120 -977571466 -108756183 212657134 701562137 618662979 -646405072 244057285 858679036 365662994 157774095 -879690952 881680914 -723528238 311771590 994511370 -483681342 21844249 -179580697 991611507 -115972069 -775409633 -108395532 115908681 328685713 172994201 -53767767 -938920235 888889930 516612986 -466155853 751335307 -647540041 670216193 799109698 735568643 -795028867 765725729 529339753 -337866805 -550007252 -981630789 -178864647 268618999 -333740638 -463199319 -520582692 269351715 509237836 991774810 -131410325 125221969 60819515 77982723 -463860530 -421205986 -677381665 929105361 406804698 670650900 683708186 233607279 865857438 -906047729 742181547 257329133 54658961 -301791927 -784936765 80625630 353753446 232859728 -361809940 -363085943 649542411 274282963 22923…
Output: 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 998142891 …

Constraints:

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

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