CT49788

The Peak per Window of Padmore

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Pavel found an old ledger of beacons in the studio attic at the lily shoals of Padmore. 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: 980 493 -562493483 332855094 -804817125 148765832 549157976 18907014 228140538 -289885230 980069628 -997368784 634901455 -646218725 -731571900 763486910 -735506137 965363047 -777304552 352512929 -105978435 238596422 27113645 -545763321 -450671366 846504834 10915884 243353569 -864356281 705370575 -564974227 -104505693 100531835 188640883 -715619438 785083722 571580003 -477754834 -679695790 837962387 -146489510 190845251 9911201 -593894678 948261422 957355882 -579864509 -948060202 931654943 -970507027 50055645 293721107 815996124 -905625018 -369428402 -584597418 87658633 -526092824 227319570 554298451 -67720744 844854123 932580806 535929756 642097317 116626032 -493031161 -185023900 -636506378 743054448 347993482 945836060 -654379395 -460850290 173588854 -497151534 526557474 446342518 6770031…
Output: 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 997071500 …

Example 2:

Input: 3700 2047 -476427584 996596423 -776413095 -113590403 -927589044 -920044072 -786284764 -162793125 658625875 233403437 -298200492 338721388 337779337 -755744169 -163685319 25144753 603947621 -39414810 267705669 118247815 -349814446 -17585081 128109991 -9519045 -44962752 818644141 -471476127 885227054 -72155693 -585289576 266019324 -461533011 56315931 108908267 -75299641 -394982880 -345575129 -770197302 321940257 -462893570 -311372687 341988488 -948826969 -47634022 348560758 -121237735 -66471057 399966261 637447195 78330441 920248904 224587515 -43740971 257540581 42338024 -576587619 765538752 842083469 -168074729 -343906637 -895385797 638537216 -624634023 -916366313 -585409545 78653742 649461727 95101303 -467042899 688988992 -558210987 -588993051 -293943366 191114709 375103600 -537374118 8835…
Output: 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 999504271 …

Example 3:

Input: 647 439 43807368 -745634285 -663147183 858608801 -161735803 601857692 384398730 285112341 854023817 764540198 510755757 142260750 -731163900 228488630 315174723 -686149148 -683346577 196434008 -405558136 877330578 731272243 -293168248 -31124945 -524938542 -657979576 69540461 877010618 438861857 656048233 524491908 606024761 -543999842 -759552850 -299006389 -217668297 680685395 611611101 795651603 817383049 120174908 -401208707 -268492180 482034114 -269815001 321697102 -933466042 -229398890 621982134 738294732 926127036 -288458839 751164837 -836793190 -120393697 386245843 -315521912 416324248 455130030 229109357 -520243557 338650288 871868358 -352351010 500086222 -582047676 -594750741 942163477 -169758800 -666609239 788628143 -457174539 -980184594 -882282163 -690041928 -570675043 585389429 …
Output: 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 981144764 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 997677160 …

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 of Padmore - MEDIUM Coding Problem | CodeTikki