CT65091

The Peak per Window Beneath Balmcrest

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the cedar groves of Balmcrest as Fletcher unrolls the day's manifest of beacons. The tally will decide the next shipment. 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: 2730 795 429878651 386757932 586769232 -685351548 -837014186 476082893 960737944 -954060729 -87322298 505363307 406460640 584211706 -289515074 -490737825 689144135 -441652312 -696846135 422938135 -698722776 -503087516 896487531 187631280 -466066547 -164064539 379135332 425205714 -411626572 621100800 -994721337 320658212 -763229839 716500598 -281579517 585815732 371066981 135351942 -210869176 923551276 234092209 -812272739 -284414360 625221772 553372458 904232395 -122434857 58682822 877614379 -442124378 129106577 -816095744 -365606750 -93049589 -146959745 953883727 683103069 -892684040 345601514 -885533789 564307817 -50061812 -931044917 732088596 -210756159 86640940 365665446 282616036 -821857961 82081241 -449133822 914198698 307678637 917948821 414162808 833355270 -551598124 -860458465 412…
Output: 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 995992903 …

Example 2:

Input: 579 76 -176848917 -457144014 709199706 -660655890 -366745554 -573556060 406210915 -958875834 974532653 587955870 -695757075 -124510171 681652380 -784097717 841589238 592262670 -192879529 -386827456 -364753948 -492995707 647400694 -519060872 -311449640 419034984 -939439184 -70566754 -475011217 -734684593 348455200 813826987 -945319104 4450122 -808951084 -957535039 172103094 301604512 -132814179 -513095943 -58422966 -561414972 -458269605 403550111 -120837687 -835160943 890977447 -141966202 -278916362 -493091504 27651343 -58970583 648902088 -968548022 807185508 163603745 654805610 218552861 249437288 -280677377 -543737560 661767389 171951756 851104936 989262582 -566492011 416648426 992901972 938433516 616227449 -830295910 -225842679 770115284 246113466 353522370 870407421 -362892446 -45639797…
Output: 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 992901972 938433516 881161947 881161947 881161947 881161947 881161947 881161947 881161947 881161947 881161947 881161947 881161947 881161947 881161947 …

Example 3:

Input: 2703 875 838111505 -743961018 189311623 -570893960 999882827 -805382671 808042895 431650736 108999627 -596748913 315191584 630770757 -965688689 -748909479 -906903489 338588784 631377938 770910595 -35349880 605664755 -511740165 -253045249 -863714225 -182899544 -449216388 354036500 -796428574 -869586040 857385975 -640863542 205528791 -466247834 -119031430 646085168 -138242810 -801821420 560635684 -374722109 544649567 83575744 28027366 209379941 -867944051 -549772490 -963825305 -175049545 -408503988 242143624 439819098 -405874620 489809225 577918344 880536410 648043334 154961521 727964908 157357665 -158607244 -960228216 -655241233 -466767512 -348252279 919901042 953770360 147214986 577413176 -342876847 932795493 -343416277 -697686317 313423464 -595717819 186291794 338867081 483899104 73247928…
Output: 999882827 999882827 999882827 999882827 999882827 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 999848869 …

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