CT45669

Sarla's Ledger of beacons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the zephyr cliffs of Galeholm opens only for a perfect tally of beacons. Sarla means to find out. 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: 2260 2043 -916604346 -138103288 -459118411 -931144119 549663938 -99120261 -106479053 -200264110 -911878109 -71728469 549830795 2775612 -841839293 -212751730 983057955 -749746150 -615323996 980374897 580363435 602303393 -529021043 311364768 -395848332 -102863520 -379303949 -602730310 -702084224 -131646418 636438057 -915925889 750491877 385634336 211435154 -54318821 451240625 -760802789 -625651416 -395845793 108714152 50128392 98342327 642807282 -277258616 862525008 -527789205 -455801193 -24918776 968120302 199038563 169140360 178907342 -258598827 631096245 612935620 -373866483 -866073387 -109857744 800879619 435473388 577645522 324249053 -638791594 72923202 538247613 -806817440 200770692 955578380 -648427267 1552727 84270453 711271631 -552554502 -201205759 -792866859 255778464 -869657004 58…
Output: 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 999410120 …

Example 2:

Input: 704 433 -197657088 69161376 711150090 122863077 493267085 659163287 -620391929 214125525 -106321406 471288040 -892186159 654778322 -303058237 -194833409 -647533535 -197799881 -753994087 15627560 -852043769 437206927 705991610 -198968795 -296302716 869300577 834283147 -193503803 598022760 -146065492 -495331356 -453649391 431212778 -170881474 951782629 -356755357 -544523085 501608743 236723422 217721317 -549353474 847822128 469257847 -707261021 -692050626 514566689 422836594 -68653311 -956964278 706135720 -125049841 -40261201 696237684 -389409260 -49468190 747068150 -715095280 -440459834 -757706645 266555447 -35675218 871829364 235553558 977926948 968947130 -781560388 972020531 438715859 -607274178 -63670796 -61796004 827230400 504088610 -814573609 -182934914 -901564542 -769313803 -765088465…
Output: 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 991469978 …

Example 3:

Input: 43 19 -82535148 355648676 -212646793 -181646128 -290232883 -483545666 -890597428 540300083 -53488251 -984527879 856306160 989095694 204511673 -94833265 -850852716 -767079331 -742693537 950418828 -578712517 588395722 -805798857 -494548366 803053439 -37549835 600121777 368946186 768634580 -275785161 -536332403 136165094 -536505943 -120824949 -606529626 -148026287 -780059461 244365876 -609201110 -952469462 -1833802 -713362825 686250566 933229313 71078416
Output: 989095694 989095694 989095694 989095694 989095694 989095694 989095694 989095694 989095694 989095694 989095694 989095694 950418828 950418828 950418828 950418828 950418828 950418828 803053439 803053439 803053439 803053439 803053439 933229313 933229313

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sarla's Ledger of beacons - MEDIUM Coding Problem | CodeTikki