CT51392

Mason's beacons Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the ivory gates of Alabast, Mason the cartographer keeps careful count of the beacons. settle the inheritance fairly, every figure matters. 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: 1979 1538 710214390 -744773651 -804589397 -738675030 410802667 -120774244 468563807 872551060 -551323080 44693114 375619065 -669271640 100349278 519176446 43895046 -864931331 698032030 -573606278 747791593 -270431281 107246433 -637466067 -202952949 -36284839 -188199243 339528781 548008756 73347741 -613816020 -718743821 857097919 169745591 403118055 274797691 432900382 77775360 786661324 702315818 -947861387 -114232542 429855800 255924935 777983497 836746543 780987112 -451173682 969724681 727061352 602897907 321946915 134436790 -384857946 372889130 -322044207 330488407 478426049 605030587 769025773 218951330 -180013733 566874206 810787217 -84759441 896881014 -823201426 198858091 832639875 784206569 -281565471 -745011094 -582942970 -154854708 -261013793 -400106646 678989250 -675072709 794399…
Output: 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 997571572 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 999195535 …

Example 2:

Input: 380 34 386857260 865290375 480657982 -446109355 526558659 -408721972 -358758932 913351055 -758548743 316325968 -417499233 47574111 -370314195 931900715 20616840 -275768826 191638650 58635283 118088298 -743022283 -479335173 -202121997 -81843428 -950865089 701784596 -105320362 -581229929 573967124 407995391 -503520248 -117968178 -109691887 -356903921 46799132 -750142798 768272993 152999293 -559787426 97983355 842880789 738163088 -682534480 -703153510 -910391498 816267352 -133209433 765496717 -4908086 136826571 138400888 -477009302 -81713078 701570668 -397581597 135336107 -28087423 190340935 -66776027 -344110304 505578812 -870488936 -922306299 -360974952 181087492 516085119 -693720482 776817395 -736691641 99601520 -340389473 -923165408 -506237986 776689286 705397229 557218905 -752783584 20778…
Output: 931900715 931900715 931900715 931900715 931900715 931900715 931900715 931900715 931900715 931900715 931900715 931900715 931900715 931900715 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 842880789 816267352 816267352 816267352 816267352 816267352 776817395 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 966746145 …

Example 3:

Input: 3580 1889 -643887543 -573167500 773609322 -95490646 303236624 969224516 -955046851 934273251 688649162 -211988028 41369633 708446823 -60089773 -58363135 -669780840 727148840 -59024356 -378515044 801212069 -933932493 912055173 507644599 -428702612 601289760 -803098736 625166262 -485920964 816730904 -818308514 -830959280 791997580 113158223 248857431 621762470 -527376461 -720178631 -106720548 624817247 -874806080 -340823060 -536658871 615431070 -254114883 -361794391 568792806 -299474705 -823526610 -371477908 -362061391 90673 904458367 -341533495 210174720 -94827615 -233390685 768039851 -619576120 759658190 -200889233 -708560232 -834736007 820978299 892009765 282509484 -902614628 935140532 939185798 719063810 -154294677 493395711 -191580073 -979957500 -291998959 780432723 261982739 -327220905…
Output: 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 998700931 …

Constraints:

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

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