CT65065

Potter's Peak per Window Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the shipyard of Keelwind close for winter, Potter must finish the ledgers ledger - one figure at a time. 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: 1761 1391 318347183 476074403 -846654308 189603273 -69071464 728192683 -357025185 19888664 -29742873 -889673518 -856064899 -234703689 -410503040 -204262463 677148795 -790758629 -38307947 86783708 68273194 -862641545 938990711 566854232 183276695 -242831082 -619138004 560773090 -755000881 3826214 -819737732 410368016 -788028881 743993849 456852920 748187167 538462206 -637771908 -9959469 -365262542 458591113 -10652021 -541318035 155459998 607877931 180662532 -502087210 301856435 581299981 -831978900 423197428 136569109 -619132420 672854656 688128205 265454215 343641890 582420987 228973911 -155743881 304784017 -7113655 -374414428 50308788 -9931962 -731227302 -452891842 -521384037 -108967563 103452856 267104089 -451408658 -127259159 -469162971 -631975068 -825674265 -67194370 -703320476 8199829…
Output: 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 998914003 …

Example 2:

Input: 3466 1570 147487909 -918321618 -351573602 -94815565 -495445290 -637767671 917253210 652187576 188235377 617838838 610529593 537226816 -948163733 -985064524 588848163 600632606 532109569 -227032680 633840916 434438671 798621425 488500727 2674713 521863200 192326615 -698342346 782652966 446718567 -405258998 893495556 -896351309 -450948335 -56407560 -831968605 764239168 -235931010 -269971547 373236370 35589524 745514643 -985662296 -201889638 -116004261 597128821 -292435898 666119801 116550778 825160723 -904080900 -645107958 502469804 743236555 -880350093 -281427203 401717145 985287961 -970718466 -103004862 -96733288 -15439965 546876297 -293484717 189178599 562946450 -813264669 -205217466 -796846034 -317816486 -508257212 -163596055 752673192 -837936268 -21906023 -998027700 -14392131 -679131533…
Output: 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 998250766 …

Example 3:

Input: 3140 3068 -710103622 371146416 -700695296 458172068 540688982 101272977 -890353493 -528253079 270598064 -2629459 -73065601 251757683 183205885 -465016581 127077023 271619423 256667026 -550965263 733710772 -368424190 -594050265 -161011493 -68849277 -596213009 -377388394 -84229509 76666283 -521206662 -100777760 344031629 -11419172 926438695 -365159084 343228859 502364551 90986240 -635267514 859646664 -809443272 -542322258 816116056 -490879709 452010060 529147561 861881329 425110889 461802242 535142823 950102780 708351727 462289238 -647039011 -943722025 178170608 18843780 -165923081 -851818216 -10041914 -314387189 -993024890 126321037 152500081 -68799520 -407100489 -721310067 747908200 393922527 346200662 238446683 691135480 96987849 967715937 -78833871 -419758119 -208793489 -229698191 385686…
Output: 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199 998504199

Constraints:

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

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