CT47644

The Fixed Window Peak of Stonehallow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the granite steps of Stonehallow, Sona 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 <= 3714; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1132 361 -212083 -8535 -50404 -405537 -110032 -370270 -875766 -460927 -633956 -616304 -259177 -781974 -617905 -482611 -782900 -937761 -508632 -648818 -84571 -500330 -746725 -545762 -35923 -505952 -744932 -880149 -629163 -172658 -78828 -11303 -36510 -233003 -867047 -569488 -145879 -813689 -299139 -588864 -83117 -419311 -255885 -526291 -270442 -448685 -808378 -367764 -762527 -134837 -864726 -346323 -524121 -429098 -239676 -109895 -609224 -181920 -943876 -333744 -132228 -295861 -545542 -983938 -347729 -281669 -631499 -729224 -513033 -99430 -561662 -659404 -780733 -16171 -354654 -249151 -255423 -356620 -724439 -115308 -594708 -450026 -750253 -719364 -354377 -493822 -732240 -184939 -332222 -269929 -123101 -628100 -439690 -615090 -871236 -976807 -142140 -149455 -471931 -482727 -452982 -18196 -72…
Output: -170315764

Example 2:

Input: 2077 1603 -858732 -363734 -992889 -615763 -702557 -997429 -235691 -566774 -193260 -244153 -397902 -983839 -859100 -107636 -344098 -166519 -950367 -406181 -863319 -958739 -57697 -121090 -258839 -660827 -633680 -335641 -920015 -751052 -168968 -142651 -548388 -575423 -648048 -908013 -369361 -372464 -354426 -725355 -958480 -951904 -132564 -271285 -63459 -698174 -714871 -164344 -231531 -66501 -814605 -80828 -599556 -352034 -13835 -548537 -236013 -976577 -239299 -104588 -495475 -120331 -868770 -360633 -503717 -903256 -952950 -331392 -106195 -166784 -294881 -925401 -556630 -394214 -809247 -950805 -910635 -818083 -775419 -118525 -259408 -121906 -525035 -783017 -928506 -789577 -895123 -636150 -14187 -541717 -244165 -49621 -606154 -44321 -878632 -3981 -380785 -254958 -543594 -471416 -91465 -10702 -3…
Output: -769479162

Example 3:

Input: 3490 3305 -279812 -142860 -305774 -121127 -741492 -635064 -965447 -650835 -576827 -514428 -995302 -994988 -410619 -741141 -294001 -633396 -818754 -709316 -689188 -78623 -315030 -226911 -47796 -69444 -981831 -724595 -38554 -921018 -632339 -212920 -680075 -736006 -288953 -197860 -29886 -361478 -302056 -822173 -177430 -469560 -927925 -828885 -994291 -481682 -999804 -271115 -715028 -851919 -417246 -421330 -902416 -729098 -345557 -523729 -967225 -196786 -290880 -85121 -819701 -14986 -640233 -580982 -193375 -73929 -340730 -300595 -82555 -361642 -425238 -490229 -875199 -346723 -731944 -805498 -731462 -373766 -724606 -231239 -345754 -992725 -68058 -183514 -808531 -693039 -295558 -929389 -617961 -661458 -221673 -730877 -211669 -895701 -552557 -780837 -30918 -613478 -393444 -1320 -589438 -369183 -28…
Output: -1648064446

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.