CT42698

The Peak per Window at Coralcove

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The tallyman Felix has been asked to compute the guild dues owed. On the desk lies a long table of ledgers readings. 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: 2469 118 -708129458 -895158766 -31503695 294725669 -724679145 935157921 627616349 -691039288 -167141219 384371076 -555979175 -997338566 562162981 -497043452 334927200 716755968 235887031 -681689665 237196666 -238716388 -121197988 581092297 -811934851 811618087 -239735492 -909141267 677568043 -690940980 272549644 798268498 113824783 -997967198 -388216797 560283702 236824134 -583418065 496662067 -745909841 451059463 290891270 770758474 362210740 4420577 40025209 -81885600 962656401 -980157685 401965937 -921601328 -280991104 -410856525 -525996572 -876038008 237193438 -157533070 -635595523 546234432 314231757 -48257886 -66896999 -538706189 -238960944 -25443503 -191800381 480364727 -943567472 837739217 224557580 -978196448 -6012307 -906734925 -620996197 -458245309 -527305482 -311777384 -2933722…
Output: 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 979455573 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 996252781 …

Example 2:

Input: 2370 1145 -871900770 -61216315 959938071 656547636 -121279099 660364848 -847118919 785616955 -913092895 -270715647 -579844053 -623613362 485187283 -850780370 391775031 -617523824 57113410 236503465 -227872332 -577465718 891854844 -898924328 -696049466 589634808 931661702 463430106 741866728 658122259 586268680 163065318 961050689 -353299776 -838215791 763858369 -640858154 962173406 -578883833 76834773 -280549874 429846557 366800385 78125672 149071798 455986445 555911302 542202701 -691146877 40839103 405960549 426740946 29351121 -30766742 761597547 476863435 -445663643 478912174 97587507 815685675 -213852207 816862240 -337554185 458349753 585854943 -480893608 -59903646 235477455 241092251 -744004167 -101098647 256837154 -578247651 -493425062 -45108046 -454278919 659167400 -700290118 -199139…
Output: 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 997033896 998564009 998564009 998564009 998564009 998564009 998564009 998564009 …

Example 3:

Input: 923 308 -539515231 -484975023 986431199 782124632 -305658911 821997717 -672813060 331329221 -253435814 861080189 -85039545 -801851992 -538766794 -99608122 419253398 999383357 -681595670 914114445 -44748140 -759458103 -206606005 -271273154 -543756242 942237318 232879021 -903381361 -987523517 -637098627 967136462 -189951383 154808598 864041472 457533818 41787697 -770315839 -308728765 624856452 206635270 619351175 -307315268 -385487123 -81176385 457897289 529669649 -85366325 -682018152 783346667 -97308066 -498614524 -100151750 -159089742 29649453 328374337 -712209954 -605284724 -275003355 -208391971 -856250971 -531665261 470136650 279698369 113295327 340930159 59029759 -640508240 -998857955 768258496 -790634553 78498908 654440964 667245378 -34919950 543969872 251160300 345362207 213760543 365…
Output: 999383357 999383357 999383357 999383357 999383357 999383357 999383357 999383357 999383357 999383357 999383357 999383357 999383357 999383357 999383357 999383357 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 994864458 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Peak per Window at Coralcove - MEDIUM Coding Problem | CodeTikki