CT38167

The marks Peak per Window Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the lantern lake of Firefly Mere as Tara unrolls the day's manifest of marks. 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: 3066 1157 -63957748 391230998 -162348356 -146031801 359225324 255980485 566663926 -935524638 849497286 764331860 394727903 -337255129 463545295 890089762 379121210 -782689975 -126661479 -628282502 440028439 -590416896 -707417634 -879503204 -270085549 905477524 -129518568 180601872 -798581062 -641226131 -186389121 948807642 -552544623 555495709 953835905 -101721725 42534473 369323654 380739986 -143697744 208841059 105077394 -619992826 -684304173 671129486 944814709 -237925448 -505202544 -167339151 334779824 -548878220 -672015743 789328407 349684129 -706081116 289858580 -65414207 226860798 604562155 782666499 -662266641 84272727 -197034646 -73427604 967411649 -114487720 -824122629 662552642 500620359 431206565 228382223 901518627 -603044318 910746132 674137974 -191837004 318308345 -407176126…
Output: 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 995245690 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 999216137 …

Example 2:

Input: 760 673 771897989 684534841 -85245787 955195936 -422830132 -835588550 799373591 -381761723 207421443 -956303752 -708976001 -353316715 -664101709 764739720 -73528391 314247379 271360369 719895671 971236508 687303758 -441833029 -858873115 333475536 383613840 -997803323 -139540662 -676309340 -127233702 -170591730 -372299943 974865137 -698925964 -724092945 -320179505 -510282504 32290712 172604678 35553191 821180268 -443643520 535126912 446750831 217902827 -944463578 383082696 -999731869 -293207042 -891807447 851735451 920291614 -987738963 -493774258 -731223476 -716879791 -838003160 -161250015 -885388926 -10169773 848432742 479881140 905259810 -117620123 9606258 302217621 -364602089 260417642 52065828 201309312 -229937114 797178552 69205017 437628726 -510963011 -351446822 -991270616 410053686 2…
Output: 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 996211865 …

Example 3:

Input: 1087 938 -205552024 -937207255 -111760841 -339196121 390985831 902794523 -414424715 -632523232 274082298 -349980676 -546244253 731149723 54714707 -954543535 -472631562 -12183280 7558114 147113290 226422216 -780813458 -834371840 -406290035 357571503 -910573920 135685866 10196957 429594351 45635028 890954677 138675760 44801396 -477417157 580139788 574051755 -253496786 -717575741 694004568 -353893126 895324646 -833680483 -475689891 -891896092 840170357 -865202923 923751173 497453219 425630524 829675177 -384815197 295687397 -393017926 -457990927 -369948497 -166798168 -849498547 -503716283 448867435 -643431301 44368285 -299049804 320083623 -719814223 -536189070 -225616191 462561857 -533781109 -635136048 553071125 816695194 -882815090 -96154819 -102988005 303987018 575076863 -577595132 702334557…
Output: 999053644 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 999257910 …

Constraints:

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

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