CT50186

The Hidden Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Jarl found an old ledger of signals in the depot attic at the otter slides of Sleekwater. 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: 1465 328 -348592187 -714610333 -323418620 986385307 -210976462 916649824 -798119310 53607107 -414712157 -297032204 -321229542 -181563274 92230077 411014127 179272452 816595428 -465328079 -399542057 519831263 625877695 -775346549 265512655 455808858 90390298 -919115066 -628690766 770952571 -864225091 -554367927 -703080857 -247592167 216633003 993735525 818658010 -466281201 -512568594 -424586722 -856514345 -274823474 868032265 664488993 -142312947 798572826 742899491 91577113 -431157301 256224759 502690554 -281431157 -124714819 569558254 187548360 592652439 -110483977 562735124 475557552 443722982 -43455861 -252975571 369173456 60017605 147445770 200730499 744329451 455483458 -261335706 -545410293 -945606435 -258353317 -809438822 172626394 356092128 -317496508 -91995575 631692135 -57915590 -…
Output: 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 994704639 …

Example 2:

Input: 757 138 326054401 -861288364 312987000 -152275700 230904886 -207856338 825255459 -916428477 337128146 648456536 -128574303 623013682 202923662 772492350 85996499 -39396386 691805747 95558454 -851578301 -173675787 248541382 131194146 -745368110 496361848 -82402810 -86172718 782668795 425205555 -558576949 656715393 318247448 -356424290 -354019751 -267461891 982688278 -817872548 856379822 448293905 745672350 -789120555 -436100905 917409587 76883713 531077345 -671449504 201686670 270314501 -66649432 -239532932 843608372 -907753704 935013078 748811386 484842115 -526703238 61052039 -549892046 866058382 -769795266 -945433252 522700785 297170908 774693155 -115046020 -217444449 355528782 467352041 61075421 266872471 -515279275 -248117002 -363659762 -330561658 -102635851 -75362106 -736910160 -575274…
Output: 982688278 982688278 982688278 982688278 982688278 982688278 982688278 982688278 982688278 982688278 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 992717350 …

Example 3:

Input: 3916 1414 -866926618 946534728 990079805 -750423489 -851821705 768046217 -755501481 591897053 494452457 -687813544 748044697 -651083850 687917530 -267730134 276224066 921263602 301272326 341926828 -728724339 -926431217 -297566521 -155663224 724161602 -411885555 745219499 -362045444 976524952 613755937 -977195546 -178046361 346850275 109237558 -52033104 743694360 -293382776 -225529440 -281709325 -446510926 -198830875 -34019939 46185906 749118702 -154062435 -105458383 -221379643 -367732330 -793977454 -105939041 -904476659 896154453 981937139 -383454860 367994717 -529077959 -467954162 -828841589 303944992 -211965890 539092827 -506195753 373984368 -192009364 938288021 -366073708 -337160277 985330294 781648608 -127473245 337015611 -477518096 344609465 -134220419 775802454 202731880 409376203 -2…
Output: 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 994364159 …

Constraints:

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

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