CT39006

Petra's beacons Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the silver mines of Lodebarrow. Petra 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: 2741 1315 -754846689 -444990819 453965916 380203337 424558951 -120901318 -463749127 -827248698 -131205479 -11668546 4299956 521736915 -752046666 -366685647 207374278 -91785650 887859326 -121683305 928623357 -744802785 421512446 410206365 690166597 406315526 893419203 -690557626 -709985747 322832709 -980369533 531900614 -680049699 -323160361 -129558577 52999970 -38156629 -931650496 -123349008 680068649 689309451 654018277 423340358 -993567084 664141782 15991772 348737675 -468732853 -499442687 -891042302 -869692641 -77135009 994495658 -704681173 -41115538 871163974 -818568042 448002412 908941049 257070551 -50601609 581541592 441074486 -468384277 611837852 685402713 -675932537 159544448 699248798 368186977 -803875442 -716064935 -401121967 -567942966 476199143 301697548 260485282 -447134008 -4…
Output: 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 998234794 …

Example 2:

Input: 2740 1008 491124631 -567775739 -695952588 876254229 -376231227 435663770 395657990 703480034 342920800 998067057 -650138677 -287644901 -310481801 -986472099 -496462548 -117561669 80831411 952525774 -453553313 -281158012 380140784 -576786564 339776560 879370202 -906928254 638997654 -906113544 553213396 -161365102 -730655441 300316316 140068131 -205841074 -981506391 -651899055 -424348532 165156311 37531642 -656477889 122446718 -888745616 -728624687 139158324 -871487884 -593969991 -396378518 917179645 324674867 860401934 974369914 -490288325 -775391666 329649178 158243897 -219304759 558869583 -828400032 85951134 -873974554 713463994 -674843030 495469760 -996027982 352590408 -353058097 -44995504 290014610 -138381804 687946188 226963313 -179691486 -814283463 -787920385 175975634 -35339976 -2519…
Output: 998067057 998067057 998067057 998067057 998067057 998067057 998067057 998067057 998067057 998067057 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 996190462 …

Example 3:

Input: 1878 1652 271833036 386312447 -885153352 852742234 642428873 575882248 -587544854 -786826593 957117221 -234509935 646524300 -87471136 -804741780 -411266656 463024010 705589972 10533702 -746743127 874305790 637733906 -155535029 -770611876 -371559558 956302986 821912559 -631021239 -423792335 -874239050 785719318 -497621841 465733522 86126923 205073966 890371807 282567567 696474965 -942146131 -755934995 -767948990 -725236363 451450549 -683399040 -921305153 850663827 669552264 551580257 -744527435 -461377047 -204678126 -159642079 -960823385 -66350509 294352671 -648101323 -932095432 -934791853 707962173 -732319213 130232319 412123101 876599354 876057694 945364519 -474001435 -934751903 -75975020 111065012 380381467 -386805149 162005829 -653987025 -101097648 523033168 330304411 -970833950 9455514…
Output: 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 998190505 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Petra's beacons Reckoning - MEDIUM Coding Problem | CodeTikki