CT53330

Sunlit ledgers Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the steppe camp of Horselord Plains with crates of ledgers, and Opal the inventory keeper must account for every last one. 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: 1701 700 -458911396 -281199221 -992401023 380577343 332404872 -946304253 -266656747 111892081 -849168338 13900998 -514080734 438824687 672811391 654676574 759074422 -40753301 566263985 -409609558 -986712764 458608474 465867961 -104474584 528866412 -952020743 405979763 578015305 -615962409 -377725715 -804175042 -654683961 -228040026 -558258055 336351545 310992202 -445260849 -430228264 929497741 924732274 -115666365 600138924 420651246 302858727 -822538778 -881726103 -109477855 350308790 280363570 -351362203 -622243224 864657814 944648194 -948802638 -466303381 399345413 891157911 546508811 406182099 -258087713 -85565452 13813892 -19593362 -678218901 -554752551 91713187 -430832543 314187606 -687356421 -485834096 439514155 482361085 -220437532 672111615 -557232773 -631569353 968426859 57222536…
Output: 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 999168381 …

Example 2:

Input: 24 7 302847196 -580135022 398251631 282453142 626074669 270670752 -927396212 872830420 481045516 867891386 404159818 158096949 -342811196 968669412 -674860890 45386318 470219033 378988539 503109795 -119455567 -806438963 -307589258 911485284 503368541
Output: 626074669 872830420 872830420 872830420 872830420 872830420 872830420 968669412 968669412 968669412 968669412 968669412 968669412 968669412 503109795 503109795 911485284 911485284

Example 3:

Input: 2762 1406 -368376709 -436109212 79526434 -203134862 -94103349 -584791496 -812118363 88256397 799996436 627517100 685802478 -507583599 -93313834 507043790 -314110769 793638635 -520569208 -237181649 559040451 -197308621 -389758959 395277047 -646267924 -132655245 -176613314 -403771933 -319690515 -133982110 104501364 -252723754 753417633 -118875099 -911031982 135070907 996456465 -363027803 149982767 392603652 923297364 171340863 957510566 135395552 970933502 805824911 893656925 157428482 392021178 -943014234 341418823 -296479808 -339028605 -441792666 -203555573 609903232 336393928 205651541 407277504 901351300 -742396110 117462852 929090150 -566889841 -891031997 824761681 860019513 -526715712 391823090 859119475 697351036 953329727 -479005062 -861932776 -989181275 -721860064 330516896 -9568575…
Output: 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 997878289 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sunlit ledgers Peak per Window - MEDIUM Coding Problem | CodeTikki