CT55919

Orin's Ledger of registers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Orin found an old ledger of registers in the signal tower attic at the coastal hub of Tidewater. The margin notes pose a precise question. 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: 823 648 -620986054 31991606 -918754270 -735525869 166360724 -387231801 -479549341 564804704 934292510 447822305 778149809 549064302 -928658102 252532525 -389849850 -592007744 908271360 563633973 -237888445 872701008 217237597 -281748519 402212425 -625204645 -33361288 -459257034 -123393575 -337222380 963449862 657652871 -742141394 470589792 237738252 679258067 -358585191 -982617953 965976325 816445928 -953840641 -310921389 28006469 -638507888 421967236 -186771297 -123047969 -974880385 -877516558 372235433 931727652 -124133201 452431650 385022834 -86362755 144784312 -701116013 -778962482 -43742706 -874420682 321888913 358765099 -372753585 92786365 -177908190 328707774 42855519 911662961 -871574583 177658693 -658366035 509624105 -445999662 -607353811 -349496678 -574177086 -778699974 637870926…
Output: 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 999089646 …

Example 2:

Input: 3025 2526 432397166 701974372 -656213281 759437367 -599749097 817164370 -806932804 -84174788 -91293767 -133865618 992411248 409265455 998807122 -193989593 -338827068 452323482 654017273 -529183941 914830854 786077601 -581441614 528177516 370194214 -569108403 -926531473 11193401 -404109418 -793740857 -366104705 27062187 232779701 699777051 100879230 -135738834 112021330 -990503398 -752568672 191109411 891201965 -236616634 -594233683 899049803 212598604 -543707521 107880334 -54258696 -785861296 -344445257 -124380130 -930701326 921891186 547390830 -682187923 -687471376 -686853146 354433724 493494119 455282875 727181793 755237975 278902305 -3471474 -897471368 -749687792 -91837183 -427227716 400766224 -908294484 -502744683 16569591 748371822 13347469 -755161976 692379159 -730175248 -217602498 8…
Output: 998807122 998807122 998807122 998807122 998807122 998807122 998807122 998807122 998807122 998807122 998807122 998807122 998807122 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 997948892 …

Example 3:

Input: 2794 1338 -919597544 37915553 -503825523 -17141366 -179445823 -313648149 -714357937 704951233 -738337719 -931860981 359815924 371460896 343145722 309119304 -496854195 850146714 758908212 -404076428 -696852846 -51789755 254366423 -197692640 -984447257 -413998832 -631688805 274518930 -677404517 230141130 -754447412 90664348 838919342 -107027695 -807143134 745389039 -794717063 -616018697 254306069 649425537 481649917 4029056 905898658 -70862892 -333713643 -665327950 -681948622 219609411 -340493294 961508402 668721168 -552760446 -852220586 949256613 284534143 297798785 -443076514 -920024464 -895364142 20272692 -206395027 369241897 869579525 844966872 -634694505 -470418299 -770639818 -117629082 -166746970 -64510127 -863293893 328097714 483072508 -248777122 723033465 -775339284 -547487767 263753…
Output: 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 997988999 …

Constraints:

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

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