CT60450

The Rainhaven Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Harper runs the lighthouse at the monsoon port of Rainhaven. Today the books show a list of beacons, and the numbers must be worked out before sundown. 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: 3981 1640 -158737931 -551505367 782562401 -441634553 -550746813 -55353706 -986195299 867811892 896166135 -325003085 660243371 173213289 -551955365 667083432 -291356609 577956451 132409393 872894941 -171636296 -792378938 993826731 204159863 736685472 928259499 -591963553 295897053 391055673 345925557 476238081 668907488 -595169137 -905092986 878304770 525466593 -355980054 -974422489 418353412 926957910 -371556602 528349347 -200137654 164873411 -740395353 18039338 -916763607 -472796439 -866532770 -689266875 -273563417 28884021 -250698950 -666829119 -450866356 -690427231 -189226251 -188159662 81583792 -879370020 154991267 -710450651 98320003 -248686420 833097886 -621858823 -841743846 290453955 901157225 -879618093 -112059068 -393382803 928055277 794284717 985870524 224707448 -502768505 -99688…
Output: 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 998865623 …

Example 2:

Input: 2177 1502 693528829 981331546 -98520903 -112871006 739342055 -228163728 582740200 6352464 -910608101 -439410359 279624275 137757258 279721906 -268879690 132729010 413472594 726639147 512911129 -958690246 203033492 665739299 343995495 -257217434 731268612 179991068 50468464 -459076117 -146310606 -552626759 861228396 -327421688 -816738423 253064351 151770124 -224528786 -242232088 -816322864 426886335 -963015383 842774898 -728767579 -372547443 420795243 764398931 688129861 445136198 -415058765 965549066 298779265 479040819 -50339012 553327209 -999107455 870187937 -315179776 181552294 -470645563 505109270 223299880 -520677822 782054497 -761420626 -708194491 522536550 -637104594 -792301139 87551463 -948608451 529376851 355212726 -624123905 216400724 -146725606 -612793119 -949642030 -637615397 9…
Output: 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 997099341 …

Example 3:

Input: 2352 1356 840096991 -127632433 850389442 -603693581 -765160944 155018655 591148946 830337252 -860040387 837597034 -166054488 983426864 -928765097 -878727828 -769183923 995918942 -515903524 -588708280 -563335756 -911586938 169076730 -296460988 -129741838 600693094 -678688452 -867885338 468020661 -308848344 625126638 -347955112 -575093506 322404628 -933707597 881617040 -51643683 241058006 -599949695 -150915903 132310215 -840252294 67329451 -4210154 598506871 986059729 321014091 -222423184 31238014 -587146382 191991639 536096920 -620873030 73512373 -463135661 426204404 -254085904 397768065 338328211 -411339219 576612137 724595185 879019201 -370514972 862779231 68673278 339490783 -703245742 295772937 -563031929 381097318 -186610605 -248987165 635297274 415228356 -223173561 -641749140 35288307 …
Output: 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 999033419 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Rainhaven Peak per Window - MEDIUM Coding Problem | CodeTikki