CT58959

Nils and the Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Every season at the anvil district of Hammerfall, someone must chart the migration season. This year the task falls to Nils, armed only with the ledgers register. 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: 1143 412 -964070919 669378280 -286664383 436291943 658700418 -390072611 -105839395 868637726 900570577 162421271 -965827519 -408594129 515657061 406895577 -145591976 948845895 -199187234 -518849576 309846507 977059536 120644329 116044646 -460891308 -767776504 -332466276 -942135732 -605991608 598096654 623118592 -871755269 -504054542 -673518422 148994515 -807359925 -301912822 592128472 -864755713 128946762 928241511 -271733932 -175663949 -837917388 52142669 818909338 435356898 -904840735 -73950288 889833691 -9048259 -982880681 703860089 455227796 645697722 -345372984 -607494230 937839256 873383695 90312458 314635065 998601608 865179043 -917156544 -449094509 -34981001 159797136 -974706948 -158985054 770364235 -596736490 597107641 706426228 401421629 383400703 -785051505 257792168 906490096 7…
Output: 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 998601608 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 995914240 …

Example 2:

Input: 1107 402 311435397 797767010 56605065 -947865108 219031635 -758826710 -712939248 445364605 185743645 -510413346 669008791 -339505465 855239081 -49038889 -527628747 401048793 -645801454 736972564 107910409 -640337887 56687215 -848183851 29400082 -717194946 200104135 656335818 -57866974 -970587379 -226465956 77962897 69657236 -979936233 -277047172 -74430732 -976133057 256203096 -945192933 434361680 -230087732 645196945 601696996 606718158 34590308 -365668792 -219600535 143270081 754699727 -763894415 -906343395 816959642 -324736042 -905732141 -432153347 -562748927 -337231404 -375039584 -864108573 351291331 -112244103 889961736 -613741473 -894620854 765511261 -810629441 -264795445 -868633697 -95926845 -34875971 -290217581 261547303 445725935 920806776 -549690671 -220441645 -410326192 856230254…
Output: 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 995030624 …

Example 3:

Input: 957 781 475493120 -304028721 -961648687 -689537320 -859720659 625723535 -415027400 828706836 982685014 -238447529 710286814 -46710075 -581212775 -857160718 -852929478 747893707 567606471 532127561 -66031809 421464447 -120717872 99344625 -164122259 364208318 -77507539 911385629 274370053 -213732941 -789605154 486250481 300678675 -39795098 -760924004 930297497 424404839 -934067778 -453140051 -829511125 -787124988 -375654172 -156042161 -998476674 -208451905 583901737 -488369380 905449446 -241061119 -750995749 220528726 668387299 981280480 839826249 277119267 320635731 -773087739 -582736901 -54177132 -159268393 -999511451 -443491566 236060814 903421091 -225230112 -961893509 -6230019 392762575 -915444470 8625229 -643688552 -802229091 -120579601 455742151 -962560461 -947408234 169299097 -2551967…
Output: 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 997452687 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 999133617 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Nils and the Peak per Window - MEDIUM Coding Problem | CodeTikki