CT65122

The Peak per Window of Thimblewick

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Odin inherited the salt store at the wren hedges of Thimblewick along with its curious bookkeeping system for registers. Time to make sense of it. 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: 473 23 -452468822 -155537975 936623889 -2695605 -648465519 -513919614 -299064108 -984317145 -309958906 -733827919 329300645 261343569 -298723580 242701080 -961985566 -474459325 -865819302 -285395027 -557789768 -787985603 -127461610 377162566 -950495089 -161856812 73774740 835994117 -852221484 438671408 -647511098 642645500 -860481904 598126699 -741924820 91049250 856039195 -594427056 -52645174 -837293899 39750162 863125745 118513849 660177602 47357059 905157694 -246038899 -777814825 476563398 889917401 -98421664 -728586149 534162141 745343625 -120379345 -739594850 313920643 471781898 625903349 -66933551 -153243842 -285065265 -252180317 914490422 -819201327 -475097050 -362394596 -482391416 465297838 -831026582 371868651 -736639397 -872747677 727965430 377319088 -927192514 -655525847 6816044…
Output: 936623889 936623889 936623889 835994117 835994117 835994117 835994117 835994117 835994117 835994117 835994117 835994117 856039195 856039195 856039195 856039195 856039195 863125745 863125745 863125745 863125745 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 905157694 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 914490422 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 842078903 …

Example 2:

Input: 706 291 161286929 903469017 40997114 2690695 32628030 -629670105 576895529 513447558 -29960899 954806826 -773809738 258858457 -801123808 -165713897 -346212254 27777404 922073553 885991026 481954972 540241753 -732185702 -652957295 125670667 -674269535 487233383 -214759104 775180103 -305101848 822389903 -714870940 396291566 292688264 -181697336 -817134331 642254182 722338483 749993905 41767970 407123648 234299258 -738812828 137026549 898487533 414780584 501194579 -609840022 -472418387 -183775161 -444860058 -869043434 824987713 -656865816 -767886361 -935682499 -587247871 -368178958 454316136 548181793 832761125 954395055 402851557 67531331 889741605 -311419428 -436619478 532051043 -952511850 11755213 -363901839 -470105787 -296419307 638502775 -164027186 -473571533 -23015711 981618042 -5728447…
Output: 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 998403263 …

Example 3:

Input: 2835 968 -529631605 326836272 -346084641 -333806428 967327924 420048844 -645321465 -568065546 504820302 -179025262 330918600 154202830 148274246 -49765059 -382620416 920886180 -267020515 634081549 131861517 917670321 768028240 714040133 606351581 -373180076 -141473427 727265281 516097055 813194178 -988222892 529979334 -850755212 585980989 580262148 389320539 -126245976 -910565852 691047370 -123071328 -585836725 587390340 371635485 714870195 267511216 766032850 549068845 -159070943 -419434374 -782480521 122770560 -719719815 -550232901 -646099651 -444038064 -806899128 234203904 -185144645 273837825 -836596485 -633647956 -766717743 -364670168 -240100260 785003604 998280441 -151692584 -942448429 635969321 -878058921 -98715490 187800669 -773522290 -621892818 -800818341 401534140 -145861502 6821…
Output: 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 998280441 997540211 997540211 997540211 997540211 997540211 997540211 997540211 997540211 997540211 997540211 997540211 997540211 997540211 997540211 997540211 997540211 …

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 of Thimblewick - MEDIUM Coding Problem | CodeTikki