CT39660

Wren and the Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the caldera rim of Firewatch; Wren 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: 678 638 -591479967 -911691841 -920440133 548034622 -502918525 -169299368 984116681 -181160838 -206709569 -425515452 -844138805 -772329744 -4161542 802255715 238408628 376632340 -602878891 -361267869 89570736 -47594977 -771253970 904205066 -884722637 391368991 -251049080 -904897526 -709632441 -719203800 -802764487 89866697 -70486550 -754486316 986744197 -993298647 375996097 -860822793 -982633598 -774744236 -323707316 -922603832 976145163 -266230582 687234655 -557896983 -505257585 -631084741 886487454 686901132 260183182 -478576440 -274936422 650917125 -146071529 710339513 640264046 616093237 38643675 -145495703 124122179 -157168119 -312784488 -304390082 -350699464 -136459829 241051046 -678216228 -960936757 930012043 637965863 868511803 -365189411 160641798 497658442 291389361 -744024427 -36…
Output: 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204 995818204

Example 2:

Input: 2690 1703 386565754 -823494462 -503607726 349922823 -917536367 -310696079 -21827763 -538979252 607658759 -509362117 -641542985 984194424 -857369615 453418847 921685449 811091984 -613906664 -840075656 339863641 608127948 -517531114 -972063468 808445072 303826352 233213251 180803228 285091216 446950687 -706011050 -297898957 593754610 800758919 -859671916 527640696 329649410 -179162725 956498907 -625731464 582605563 -730467875 -18853907 -549109870 -202525099 972994068 903620081 156782 826963772 -988514150 -535247249 -676486071 -309677515 -850400544 167210549 14254508 -209557964 412160660 -538906884 951365042 -742163295 717581588 -608655378 557637531 773075716 18961760 181713098 896541038 623177407 433002318 -640382811 -82967669 -589710408 -899760427 -482640449 -784198653 -706148923 242728115 …
Output: 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 999370536 …

Example 3:

Input: 1729 79 704811032 -966248092 36467333 498457030 328747007 916353017 636302124 -810512463 -219035128 -311934261 -831755674 736587263 -214096689 -642661445 -921520218 -8771863 338258411 -283416884 814409917 219209238 -746015253 -745918765 71879329 476141960 575733905 952280934 -292059817 -19238963 -501825957 796283619 -469769012 278561419 669270892 966247524 -92494572 -483899040 906243380 -486753999 954260128 353099240 941773115 662627066 114908590 724139057 108734775 428013374 -934221604 637688892 170184690 -655320478 958613250 -367879215 478308249 760131908 -660496280 -451576730 -181035743 883321433 377125998 -235832069 572128004 481913151 464074426 -13186804 226084135 634547970 -337460936 465109834 -522314040 -137449029 322213767 -240672297 -12959635 -504006150 47028590 -216037811 4361229…
Output: 966247524 966247524 966247524 966247524 966247524 966247524 966247524 966247524 966247524 966247524 966247524 966247524 966247524 966247524 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 994781596 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 999009560 …

Constraints:

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

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