CT48346

Tanner and the Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the rookery of Crowhaven; Tanner weighs the day's marks manifests and starts the calculations. 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: 1473 443 -560836269 349999810 -662684863 -602997938 199548692 -487511032 -162010509 -820440657 36318483 123435289 820562811 931805981 784491904 -165790423 465898463 -284525541 31316543 -666354879 -680385011 -974899476 323089662 944011977 -298850606 -397554441 -248139673 379987418 -545246144 -537678187 838669780 701014641 -279625131 -693897025 -167407556 -188700653 1088737 539328963 620981822 -436853958 -28359033 -270112217 658909519 481288523 709370950 533771399 849353317 492667545 -816685549 -281709359 993205826 974548859 -293531736 -365331334 125336979 406070961 871284150 842580493 -341721857 -801865328 -888121834 445044411 -65057768 536528296 -937146980 452598670 149443253 -829922396 350441098 834967944 552179154 276479855 251827391 -964365153 -687516559 209508632 592543150 -49574143 -9…
Output: 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 996075570 …

Example 2:

Input: 1366 175 394271764 56946295 -404778583 -858537031 773613999 396693449 -153399218 -694128741 617322278 43576459 -510258868 204788277 201197357 -445632510 -981776053 -614480695 -389688480 -314693043 -270515053 706291463 -932713474 625412283 -299015607 -236499255 506945875 -476661168 469042997 868116336 265808101 -745319190 -876345455 318787094 -436675852 876121619 -479444191 -168119827 -488126222 -719381962 -80536454 -607286032 147545331 532171609 776991289 -645508063 -542303918 682790095 -780021605 322366986 -377137074 -854640852 -202627410 63667285 630930930 -755480333 475758457 -112438802 311082185 175604790 -864670504 866103627 -79326468 25669117 -929001426 338931739 914008641 20707782 -701386512 116006635 -857818182 -541102168 -739237629 874365151 -712936135 -894226904 -145470934 -11394…
Output: 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 981686199 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 992834435 …

Example 3:

Input: 3234 2068 649789836 -102122165 548457584 -674853299 162020304 768666787 -19429129 996844461 -992437879 677072859 259484605 420091015 395246887 -448522801 -922733194 93252105 46359967 -385476412 -118853350 543257073 43741371 -579441228 -635820914 -65953135 -424201324 474984507 363167133 -500853761 671123189 865732960 -506238512 577199402 724731028 4016699 -926707309 -790788188 184844876 690755944 230239641 -57626193 -275798549 159401595 603294797 -102956092 -236864194 521080611 -590172736 -389228288 -265805992 -407146775 -761387346 452382462 712346929 -816836737 389626583 317877974 285838546 -175761214 32347333 227874124 558480847 608531792 -11483252 647563026 -685115821 261179990 702626723 801057518 881171370 -148512551 169883744 -377079386 -919437647 116774588 604307094 -743517755 3823619…
Output: 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 998620734 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Tanner and the Peak per Window - MEDIUM Coding Problem | CodeTikki