CT46786

The Peak per Window at Rye Hollow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Wren found an old ledger of registers in the observatory attic at the gristmill of Rye Hollow. 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: 1722 1143 -53712780 521712515 -619802564 43759314 504859027 -811642942 958346243 -325341870 -437079483 -179311015 859102334 902685455 -504540551 761567877 -119827177 36610451 -554212123 568763862 555268014 936361709 -891840184 107401989 535311267 -930048938 -773478992 -699610101 947984386 -476973670 -693136676 -830723674 -683478808 -515312013 -220313154 -292748449 -604485726 -941866893 227207890 -654373888 -599169161 -735957097 -570707465 -448597582 -816485907 883376095 -896739561 -657763415 -888954640 -952060042 -441458712 347563871 -264228171 148416348 -550852605 -642345902 297111268 189861210 -49348942 343692960 -388203074 -63016972 181215238 200327141 -798289671 835686344 213777490 250348866 806001830 755318564 -891809490 -493482001 723628057 -737770330 -121917545 507462993 -505519264 …
Output: 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 999809494 …

Example 2:

Input: 2321 1629 -194426171 743343516 -218161591 -225157937 365148940 -321549931 427829468 -943027532 -461867769 344261949 -271509667 -515058947 -203777761 -218492497 -236356288 758507274 776435505 729614162 -709971617 -457789281 806644374 -219022130 946938264 182301507 859534894 496132447 -226568285 -206400725 351818181 -145558195 -394033498 916067951 701667424 -187899561 576258532 -847430649 557056322 92204770 -483865743 -302144437 -372084871 -863346239 -848327878 316595122 310897645 812601894 -849021680 -548171405 726564300 -952869869 624408630 103239610 -937995165 122570722 -556400562 -296004767 -84129676 -929786969 378224002 347253089 -811216438 -394080728 -409122578 -350254854 -221383086 -495348990 87688128 935900887 849955955 -851642985 -835755676 -69340913 54590791 412494244 852922893 -10…
Output: 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 999028513 …

Example 3:

Input: 440 77 675605883 14220272 -862988612 967733467 -143322600 -48971782 588869267 231384280 -601860632 -297844135 -957794835 917087759 -130671897 101103516 824373298 27146600 -591188778 -438558130 -711830611 537999773 788096457 485338960 594494970 -879634843 -647627394 -738926688 108646340 545888312 559918095 928878203 710805418 -830106469 963101936 -845578232 19074585 702768858 817189909 28625460 -644189225 536935268 -73103000 -71535011 -660111121 -95303127 891220440 -785171434 -765421535 883929186 461518089 -712906381 152204415 -616645218 -57255833 -665294669 -224738391 978048724 960042241 154410198 -136634141 -427506486 -667203736 -805866811 548139746 671576257 -527283390 -536966653 -2496880 -919247228 -269947762 -918453998 -681482979 498063556 -270423120 -486194694 138859068 662346216 -586…
Output: 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 978048724 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 994254612 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.