CT39307

The windows Fixed Window Peak Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the sulphur springs of Brimstone, Rowena records each windows in a worn leather ledger. The guild wants answers, not guesses. Task: Print the maximum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the maximum window sum. Constraints: 1 <= k <= n <= 2784; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1623 858 -410410 -254473 -799 -471141 -772131 -573321 -883913 -441682 -748606 -345550 -502680 -182757 -341675 -495498 -550951 -828819 -373632 -617248 -951089 -307924 -736668 -105 -421016 -562684 -203678 -177389 -26211 -893753 -185169 -190261 -688849 -322457 -525665 -369314 -19111 -20266 -265674 -774254 -342061 -603205 -379588 -631182 -763238 -767837 -503408 -15028 -668880 -273003 -923037 -769038 -133453 -88762 -735641 -179693 -715716 -393986 -317846 -610732 -641307 -331539 -962811 -733574 -199635 -333160 -646039 -947332 -397191 -685797 -243648 -381562 -638931 -507879 -122214 -969784 -533462 -445028 -530219 -760724 -33756 -158755 -581727 -605319 -19106 -825337 -280837 -177711 -956242 -534940 -871350 -887460 -869398 -780837 -955237 -134234 -827618 -534972 -718693 -606486 -474596 -870525 -208…
Output: -423101524

Example 2:

Input: 1542 206 -161088 -547943 -544353 -349737 -7539 -677463 -513751 -926245 -813740 -211698 -122112 -772123 -676185 -672915 -994171 -883516 -984761 -14757 -770083 -865483 -804547 -62943 -24013 -922165 -844005 -648205 -574383 -428396 -996277 -782422 -459368 -191383 -594877 -495750 -929542 -796510 -477090 837 -969182 -165112 -835938 -133811 -784792 -163671 -812878 -805640 -473299 -891880 -730255 -32470 -654480 -531923 -746090 -186683 -153788 -596422 -991222 -928997 -929377 -883637 -211369 -867691 -848478 -400431 -447238 -141364 -999610 -232652 -964638 -219148 -26755 -409896 -718529 -694784 -534198 -273446 -729674 -368605 -33397 -841269 -592321 -125030 -375599 -25331 -755226 -276406 -406750 -810691 -367246 -873196 -565913 -973793 -623315 -447506 -540098 -741247 -95086 -354315 -663267 -359431 -3937…
Output: -93096835

Example 3:

Input: 1131 987 -594295 -833136 -169795 -895667 -17071 -893046 -561565 -630916 -891355 -170097 -328972 -492479 -470186 -486651 -159329 -826867 -207100 -132408 -905270 -681879 -564804 -264230 -802371 -881779 566 -936866 -824818 -344211 -185938 -507482 -385932 -196798 -485780 -162588 -638182 -566874 -886988 -615093 -210980 -964950 -466855 -331360 -17184 -15537 -170188 -997970 -361340 -605968 -411856 -893173 -565921 -536954 -769456 -563640 -684808 -933252 -465005 -615603 -342557 -295096 -105533 -236778 -961540 -364794 -111277 -787821 -67473 -494799 -177129 -280031 -169095 -953499 -77304 -738066 -395503 -342717 -870081 -956899 -800732 -755665 -955088 -608788 -157869 -225634 -674631 -650376 -738024 -829681 -672957 -757034 -598478 -889055 -420096 -342654 -477796 -907335 -906182 -134258 -619216 -264830 …
Output: -492151190

Constraints:

1 <= k <= n <= 2784; -1000000 <= a[i] <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
The windows Fixed Window Peak Puzzle - MEDIUM Coding Problem | CodeTikki