CT37211

The panels Fixed Window Peak Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the ferry landing of Crosswater, Ulmar records each panels 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 <= 1711; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1445 321 -146426 -126812 -512748 -865512 -951701 -490769 -33927 -535495 -651039 -261126 -304560 -289141 -53245 -264290 -564001 -965277 -682158 -4481 -452082 -211337 -561256 -106988 -126583 -317838 -58679 -270481 -707213 -972783 -313880 -975071 -967220 -91394 -904769 -577078 -542112 -872269 -65564 -121359 -805998 -844294 -939801 -824914 -637689 -187299 -804385 -357494 -676186 -626106 -876867 -239661 -680429 -27602 -49744 -791544 -995131 -42439 -604303 -430380 -785232 -287282 -992076 -984211 -30482 -66257 -345355 -204609 -821657 -481164 -583410 -828972 -617554 -56944 -905580 -705220 -494866 -829797 -484900 -832327 -969366 -175733 -790794 -304318 -570529 -410930 -265933 -433965 -514356 -549984 -273678 -194671 -73239 -824538 -631673 -331829 134 -558149 -914198 -383757 -267823 -348696 -124243 -…
Output: -148794605

Example 2:

Input: 694 243 -760261 -5658 -711560 -531778 -601686 -756379 -139750 -4665 -54056 -355350 -351955 -444021 -413018 -946986 -442973 -688422 -449655 -483836 -527380 -662743 -527235 -320740 -74697 -103458 -695572 -762186 -104740 -309902 -566245 -898527 -753086 -394594 -35987 -967021 -476634 -8865 -235560 -919852 -523429 -273156 -422475 -331708 -547675 -530302 -276861 -797355 -397833 -436711 -531582 -754016 -65820 -646412 -908039 -890385 -146763 -176588 -231781 -366434 -137062 -897361 -422245 -437809 -961556 -475724 -278656 -973687 -917600 -39508 -352576 -544067 -269262 -639148 -93599 -883292 -838622 -857494 -464926 -261695 -910192 -985449 -696758 -886820 -3464 -40413 -691566 -377094 -627265 -899613 -126581 -14392 -101010 -669755 -531975 -124782 -211322 -669453 -62349 -796598 -152432 -498096 -485020 -…
Output: -110787134

Example 3:

Input: 971 500 -952478 -365422 -174305 -884448 -245409 -565644 -236192 -890851 -455998 -750355 -307838 -857471 -649032 -589476 -15502 -919013 -23454 -530938 -72662 -723954 -612422 -666218 -383979 -310210 -321354 -960650 -347444 -218652 -406774 -413007 -362085 -195531 -742611 -696037 -498675 -65853 -236430 -896147 -827481 -525149 -379509 -605139 -123037 -426525 -795647 -385073 -758904 -185193 -45524 -351389 -453205 -871284 -303635 -935715 -727130 -597946 -414448 -827458 -571305 -798728 -613190 -696222 -47801 -112811 -903005 -930611 -749448 -849281 -195699 -316229 -953765 -200218 -380956 -587952 -133545 -178258 -396572 -91694 -136493 -567907 -351064 -886438 -247195 -971554 -517869 -251137 -122650 -64369 -358771 -167335 -799988 -447710 -91127 -214679 -350983 -281648 -27319 -537150 -398696 -613102 -2…
Output: -235104367

Constraints:

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

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