CT42700

The Peak per Window of the Lazy ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the trading post of Goldmeadow. Odin spreads the ledgers records across the table and picks up a sharp pencil. 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: 3367 1209 1881814 304551685 -473709458 868864196 -199197056 -125294874 500987712 781874794 -165262709 716561788 851720714 -279207586 59750226 450390564 351767318 294677515 575569233 -741438270 -291461568 691556960 -974272164 -923301534 -211997983 19838748 -433668414 -369636421 438224825 57047724 423061264 412161718 -62990414 -46175664 155143382 -116624575 -189328381 165966516 421368353 758069529 -193726427 664731658 -259871011 -388616765 -739870330 219165264 -704897635 -825446663 -195344682 822153684 -458437305 775157468 792923946 314428851 -843529091 -68742527 -729366339 -809330273 -123997610 4983311 -559897565 -965786825 -8597139 -563962837 -95697105 711414329 -511370906 -505123103 868401216 -672808277 456746910 -574064263 -223550415 694515275 -516596457 156010977 -748946273 -989858318 4…
Output: 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 999559731 …

Example 2:

Input: 2276 1586 -932111947 -529046187 -34221398 -867816635 303140109 -339909817 -392822313 891895151 -925688260 -893233433 592317 -348466968 -13514136 -636970285 473467824 -425152739 835793627 -3646248 -686327403 697264320 -646884270 707400044 625327968 481619563 61789206 -37666388 -551960250 824815172 288356967 24082983 -940748687 -314311678 526305180 -705067314 264229858 -589794298 -163076959 656171472 -173013504 -700079132 961136233 -262518406 610311290 -950989051 794317176 -64894892 433601058 -495455829 -884813362 -843300636 -250333960 248363319 440212031 -947419005 338079227 -305827679 -933945826 -429132934 -317782563 -957035342 492458417 -405511314 -741241621 -775307376 877031701 -633596481 -158460173 -359809515 -44322479 328637791 435501414 -910678950 -921026534 -979529199 -621219069 -905…
Output: 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 997814481 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 999365287 …

Example 3:

Input: 681 606 -708074704 408564791 251817862 565194532 237534470 301457465 131024223 973841367 -434928516 254177212 -881594535 964743248 -361463010 90362569 82928483 409017076 258016186 -16977363 -150453064 662890282 321754099 -631183516 -226648679 -484937274 367629083 -210930658 479865844 -875279212 -673361206 -380607107 504058557 50872027 -69013317 109316977 -988507473 757670637 -651043156 -855601263 -333458805 877238030 697011685 -687441967 -632462287 516463646 -391491847 -772482167 270411052 105530472 -302782962 492131541 399050598 691319027 -816584273 959914464 -806292575 957349950 -390524011 100367453 -988991229 -34328134 -872828020 -324620700 -965464001 -572117711 578646759 -560280164 642412991 -242949443 -465668016 -125362925 -747106304 -411513916 8467509 -12982714 80758841 -164991631 -9…
Output: 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704 993553704

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 of the Lazy ledgers - MEDIUM Coding Problem | CodeTikki