CT62592

Rhea's Ledger of beacons

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the cedar groves of Balmcrest close for winter, Rhea must finish the beacons 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: 1461 809 -922655084 380584045 -318696302 -444310151 -171945386 -945808558 -808657455 -466364579 185971724 -766649122 -826290963 332702630 685487528 385298843 306938690 945414617 926758575 840426401 676966011 -196804074 -657086112 -536087609 176926398 237437162 710606587 -380411523 555389225 260249614 872581846 369993823 -272969018 -235503582 905852447 -206311129 738915480 -785003100 729047383 212490153 -280963071 396753168 -705781952 -7764829 140099731 47992230 979594519 -377779487 622584980 444313494 -164940520 367430566 -220662216 -542001743 -941133915 986573950 690019673 76256478 -469619915 -27070086 -849629155 -801442326 840305544 -513703945 665330070 -223002364 -780660498 -468939478 852907106 60879669 728998971 -558732489 269480258 928816018 -444462013 502672024 351127095 425084269 -4…
Output: 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 996850122 …

Example 2:

Input: 2027 952 73070408 -834205289 381199794 -660697503 253021089 -7765868 -719833527 396904736 -30234183 -486361532 700778319 -841542736 587904012 -235680992 -176062833 909990883 213299619 391194396 56914960 -597847033 364735881 -194595203 -324742647 478305810 150680408 -154000312 560787664 186154801 565223073 197869584 -851440309 12806982 354877030 68273650 -750240570 702072781 746882059 737021214 348590499 262204216 784513258 -668161922 860393931 654111450 -892620748 -195472204 348072014 674859136 831808154 -983858533 -683064144 -277347151 594476795 793215277 -250638490 -258227087 498548553 -259064266 142127101 126524938 -844612416 -562759263 -59517135 263209263 606297046 821008953 86384868 -942546839 510563401 -936988506 929770706 375296727 -759868479 797844890 -178103298 320033400 756698423…
Output: 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 998492286 …

Example 3:

Input: 82 43 595849614 -56630472 -752415814 -946623189 -673455615 431191758 789942362 356152114 953039809 -297246312 -552439107 -142072613 -564169768 747246376 -721618691 677554107 -794961434 -455266644 -460098239 -518092119 -761704126 210036757 -488098624 126869040 78020108 -301578587 713690209 -277920366 -570570032 210796268 325091937 806284512 968445805 850651701 421043703 594896787 245861505 -54758821 -318142271 110849571 667116744 -369467969 -715564674 250976551 146489456 -528884939 -700081213 927157271 -65066032 447063783 -240119741 870169773 -193901008 -346983016 64881981 63001728 -761557950 308637103 -775430588 575247557 799867487 -139205799 -152543569 -211106416 682773136 -823876759 -751295286 919826176 790535556 -27826744 -381848388 -700919948 609452748 -296994692 63891233 -285784921 -4…
Output: 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 968445805 927157271 927157271 927157271 927157271 927157271 927157271 927157271

Constraints:

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

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