CT36808

Smith and the Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the lantern lake of Firefly Mere as Smith unrolls the day's manifest of stretches. The tally will decide the next shipment. 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 <= 1677; -1000000 <= a[i] <= 1000.

Example 1:

Input: 723 599 -996054 -575540 -779930 -121612 -288816 -659315 -157736 -626793 -845029 -361211 -633001 -632910 -869984 -594487 -881461 -636442 -835161 -449220 -327640 -739505 -853089 -476405 -750190 -955165 -754633 -212900 -257548 -226725 -609255 -457886 -705883 -860585 -491216 -739388 -266346 -349724 -694274 -585239 -201054 -144872 -457038 -243159 -769883 -538995 -208591 -86545 -877782 -428251 -367579 -375845 -561655 -283692 -439908 -453596 -123577 -455788 -461184 -854222 -71583 -16981 -241888 -530862 -286278 -12915 -602034 -177165 -897541 -156402 -99817 -511709 -330296 -307494 -131857 -870394 -691391 -636021 -971932 -146306 -907633 -911566 -620056 -753326 -626894 -827277 -52394 -922911 -552314 -591002 -545751 -561031 -772701 -510826 -926415 -90091 -618144 -398930 -939728 -694458 -150999 -677669…
Output: -294587268

Example 2:

Input: 1114 407 -658062 -692163 -113857 -975154 -742932 -297374 -216753 -13981 -427303 -554962 -836548 -214956 -133454 -170850 -96489 -136682 -640362 -919025 -545947 -772024 -611942 -58595 -968739 -769341 -860398 -65888 -263838 -647562 -381262 -206598 -848009 -277885 -697268 -310678 -200870 -70297 -177996 -241636 -56368 -269648 -982265 -282535 -798834 -684253 -419746 -188930 -540284 -802585 -888365 -946786 -440415 -800976 -123493 -35270 -688745 -974896 -792328 -897975 -767092 -219604 -568357 -996503 -920796 -885780 -557370 -341751 -816345 -704238 -244135 -194052 -801155 -14558 -309462 -207326 -521896 -212345 -517563 -450209 -456072 -392416 -658799 -893590 -147289 -999374 -50771 -67707 -641530 -124191 -283424 -38625 -486115 -978811 -998935 -877688 -991651 -484582 -734620 -604505 -132124 -906624 -3…
Output: -192465751

Example 3:

Input: 637 226 -477649 -813510 -225429 -957352 -396303 -289477 -136117 -726214 -67082 -958244 -716945 -225592 -970313 -872691 -691081 -408193 -450132 -834759 -535679 -476939 -574924 -323694 -828212 -938256 -351294 -546500 -609195 -965306 -154888 -919174 -917713 -261392 -758109 -425494 -545064 -948129 -223070 -59105 -983715 -580837 -387338 -242690 -706853 -98974 -768039 -119708 -483715 -212050 -887443 -371911 -54587 -665521 -965495 -259454 -382228 -161189 -112384 -323493 -903230 -824865 -228697 -631318 -2304 -726586 -812409 -529793 -818072 -729293 -121896 -971097 -90601 -79973 -762622 -507249 -124212 -980452 -345935 -175964 -588672 -31113 -768496 -780295 -563294 -629697 -278863 -363384 -889441 -809037 -886439 -684239 -895528 -178537 -33980 -982374 -690522 -216627 -982630 -741076 -304853 -632351 -1…
Output: -105472344

Constraints:

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

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