CT64213

Mina's Peak per Window Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Caravans arrive at the seal rocks of Barking Cove with crates of ledgers, and Mina the registry keeper must account for every last one. 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: 2971 856 -269880258 199450362 -578051526 -670090531 -835013548 638186776 412155781 948267366 147335624 -522288794 -127816251 169902059 -204045519 -974308051 331916570 -591776389 372982587 -134073995 -836667044 440410015 834792432 -830162230 843409032 217640032 642024633 -164392485 -961871317 104153141 -67712268 -392852264 -660828596 -74615837 70376626 218390105 -771380787 148965093 510597499 -932610294 592609555 -752745773 -303303704 729155600 -182376754 281882973 -991075655 -280750179 -627872221 -444966710 -554781959 -286358417 463445205 -950154228 -919699386 -539987300 554127121 -325519522 -147508649 -973441178 510945698 -172254285 -212900914 137831667 370445323 -658527181 -585982852 571744647 -94797013 794574432 -109047713 -237960681 -309461167 687860961 279540735 -393867651 -506922307 …
Output: 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 989805741 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 997324307 …

Example 2:

Input: 144 136 355130760 396960965 -60981395 -657760121 -792090613 -834587263 -512959092 -615383039 -744652398 623318556 758929394 -419395740 657615773 -853291383 612202659 830114135 911718365 -801172912 136236005 620366550 -346794751 410950950 -483753438 237205676 314671410 906708234 770224361 -898417841 -67878265 -767258227 509175129 -149068007 90429670 -557403329 168394196 373176135 -964450150 399069099 -632010977 -637371799 977926384 446190669 817717425 -208518039 -29857658 -402017653 -857880651 -206079138 480066148 532438970 535431291 442826859 692821644 766079951 -230254595 -922147822 -449228608 890860222 429573291 779182399 515636710 -327006977 305198913 -837574044 269064961 298254096 -127926145 933319675 -951383803 -772458154 81520551 -856943680 -170868253 603026049 685535555 618331955 15…
Output: 977926384 977926384 977926384 977926384 977926384 977926384 977926384 977926384 977926384

Example 3:

Input: 2852 1316 -670348761 -953865831 -905229265 683648733 417397235 783964907 -284538724 151420418 -802094041 -766542939 921525046 -307284485 578583582 -604553154 591594036 417279643 -79495550 -368978024 -759401286 -501925337 -782695013 40539913 -284301426 262402311 116493297 561859720 406755479 -443134474 744048772 57094418 53197779 -511010073 514117902 522335228 -390005384 964695289 -859603122 -192874751 -730416107 -860362451 -323422698 259108505 760511996 -257990805 -101672610 585826913 -252630640 -457126198 -450100707 -589132516 -199264938 71299800 472033278 -102300701 23734452 882110009 -657809947 543646563 -900263779 -110350584 -614185425 15732331 621578826 -478066972 627005893 -928329916 -356362497 499504774 -606587683 873543215 -969716700 402928860 -763915180 482282503 -986160974 447383…
Output: 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 997632204 …

Constraints:

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

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