CT62250

Kavya's Golden Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the glass towers of Prismhaven. Kavya spreads the beacons 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: 449 398 -373350499 868609109 -612672787 -370252206 349960785 -825362439 18156521 431445317 -506000016 873117987 -448762609 -979173396 764169115 589613027 117996610 -388822884 -226846392 -768299336 489684897 -629148364 537115426 -307136279 239542566 -451273939 -908120020 312417992 -79032167 -636137630 322896406 -681702611 865787802 789063171 765686750 -722442106 509650345 26581020 80752063 -897176041 930455058 97776711 -916171001 87851829 -13165244 -793733341 -711229104 -694289014 -540636186 -499377968 525363486 51803039 450778257 790065878 969610082 -977090042 -322693125 579723693 -364411021 697901842 203499857 339090603 -873397748 -521297000 846131394 465092158 978765288 -17578781 826541732 737718418 -833830458 -173950181 -862467501 711525879 -722840424 -946230421 39293063 -109816471 8221…
Output: 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714 995809714

Example 2:

Input: 1599 257 -706763227 -531208727 234872524 747582414 -274175180 640377244 659912675 485962248 -137345896 -509407389 445751325 -775317008 -259636699 197009482 616803160 -824642655 -926679779 -12731453 199457186 -138607695 710262489 986735411 -748023375 -3480502 -452989953 398614457 778913462 -476240656 -500336904 -239059267 -865092916 -717681011 -182347556 461672086 277654291 -224997063 342649824 365520043 -978461480 273031286 39714038 -948977660 987955386 411918780 -39237162 668826234 -890889639 884106315 -680997754 -461220782 779986655 -166955833 800365696 168042904 376220701 328120747 -840805763 167311656 -170948363 -372714282 773346551 508062082 628002557 974048140 227191781 -707386051 -719501217 -434690433 -122226728 901351848 -790806870 681387881 878100265 814397516 -766736689 566766160…
Output: 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 998844062 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 999986293 …

Example 3:

Input: 2816 208 170469438 843232955 503979733 203074276 992014672 974442216 310993418 29424107 -344305793 286055030 -356414641 -480953756 764195461 877847167 -965905669 169825631 585306842 -960395320 -288080799 905849325 90472228 448985899 504611849 715474088 827112324 -651081896 -189922071 712586596 527573810 -318433372 475903435 -110567212 504939128 726044063 -56974859 165347598 -74463999 -291434409 111874540 306948118 814224170 -832240254 529817780 -872821100 -68999259 37779910 687378662 323876306 160766533 571405240 -915127122 909802351 -102498827 -605226359 830395431 -731858399 186777421 772672096 -270456505 274453724 307877906 982631411 -482462552 -848231613 -986910345 139396706 -954458162 -369911828 939597325 -988148792 -679947786 -889760779 -179456136 240252332 183321994 45234540 40125388…
Output: 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 994100027 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Kavya's Golden Ledger - MEDIUM Coding Problem | CodeTikki