CT37587

Diya's registers Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the herring shoals of Silverfin, someone must settle a dispute between crews. This year the task falls to Diya, armed only with the registers register. 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: 2674 1015 -116181064 415145027 -894600414 -928928580 -504361222 -751995878 -215372024 -458729545 -983236628 638018893 -678706412 369670065 -638979787 636795802 47445400 197628627 238514706 411825705 -262591160 -354014568 -623003920 -362145387 493939934 -159556691 -639032002 -907238746 35248806 595176290 789770750 -618863018 -198305808 -612787446 -532901718 594487623 162191867 103390894 132841833 307847512 168864399 -499913768 -611676924 -851898501 438263116 131256655 821696918 -854669826 85174431 -75205561 663823975 778517839 627661936 104864880 -678097453 -104983207 148856166 503721120 -421885297 -761799391 -67637367 -124681958 -736645624 82409483 114560216 25412055 679609748 503671711 139377525 647532152 -792864099 -999633397 -755116328 731169045 -845419330 -47228508 557998300 105835473 …
Output: 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 995920096 998306198 998306198 998306198 998306198 998306198 998306198 998306198 998306198 998306198 998306198 998306198 998306198 …

Example 2:

Input: 928 63 -835924345 -210536212 586455149 -628582054 -466187703 -931395109 -610857088 443574894 675795391 648536781 -245215056 886744768 -696675322 925734950 -612927497 -396188515 776265400 -837921962 79289975 -504317079 646971269 156763707 878203773 16561811 -358782519 223285116 981235476 -573034779 -230579693 143998413 -112555527 -593417149 -990912264 -483116567 974228723 632354032 72591259 -632653493 -83625422 813948329 228807147 -82999219 364411953 679199447 -976797158 -156434629 685221585 -805138771 53747369 669604546 -140401554 878764215 676248235 -39777267 -577518046 529673977 281692983 -165573392 540684077 623215834 85042973 -932456722 60194 -45750487 605521088 -102547701 864878907 -588448736 -919878605 -173010444 407384248 -167118115 -646763934 -977502665 599004052 -793079227 -447317…
Output: 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 981235476 974228723 974228723 974228723 974228723 974228723 974228723 974228723 974228723 895646247 895646247 895646247 895646247 895646247 895646247 895646247 895646247 895646247 895646247 895646247 895646247 895646247 895646247 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 962242306 …

Example 3:

Input: 3555 2902 49821895 958831624 154654134 -385468481 843801169 -611863315 -560325613 -257834870 -601499053 192903144 162281713 616005613 -851009781 720600777 545006074 654345693 68969469 -479008219 965013199 312191766 898240396 -896923940 -168774599 562679899 555020481 -510422819 -891242561 579338395 -240862251 605983938 -183737960 993099447 793017204 953315295 889746580 301101430 -777406317 855670238 -483319351 -485381042 736011165 143871867 867219485 -742853679 309341852 -293743969 796167328 124949207 427160569 159222320 -431790758 995055852 -904900911 391310672 -905937156 -330842531 -648889219 -579554007 -717086751 -776604646 -104473535 271310089 -290983063 -317405290 53889636 780951358 851710796 -385325183 -117831933 -631003859 383740558 -57939961 557859054 539469706 619575609 -188373218 …
Output: 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 998570068 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Diya's registers Peak per Window - MEDIUM Coding Problem | CodeTikki