CT31589

Last segments of Pia

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the northern keep of Frostgate as Pia unrolls the day's manifest of segments. The tally will decide the next shipment. Task: Print the minimum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the minimum window sum. Constraints: 1 <= k <= n <= 2795; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1669 1281 -8675 -822787 -276827 -171379 -881683 -753832 -53395 -547306 -851775 -994038 -718873 -110012 -329873 -305398 -252571 -549349 -819979 -160633 -123635 -583337 -405531 -562862 -571327 -2781 -899211 -476791 -845169 -518855 -284881 -199007 -416323 -609844 -326174 -396640 -694015 -690738 -417634 -756425 -676125 -312665 -338837 -901358 -72073 -278406 -126358 -457399 -809754 -310428 -334461 -576615 -883661 -57143 -191337 -290058 -265593 -986515 -44609 -523312 -930934 -917686 -827583 -507587 -735954 -568915 -645887 -467259 -609133 -181161 -527229 -327975 -926174 -786769 -786354 -154628 -613545 -994434 -202409 -23550 -33122 -1146 -181677 -735006 -882749 -720032 -20371 -893362 -303432 -286172 -641834 -669437 -835078 -289363 -901137 -32750 -125644 -308874 -602130 -700065 -732340 -403546 -669…
Output: -661130896

Example 2:

Input: 1244 129 -395685 -504679 -580952 -259088 -989518 -106888 -92609 -650261 -206458 -3154 -796228 -108107 -265098 -89711 -649849 -687383 -715447 -955161 -31283 -976846 -838465 -326850 -923321 -582242 -86628 -326111 -793239 -727913 -651617 -198307 -628762 -921865 -872667 -266071 -351786 -907828 -843044 -777768 -816114 -482782 -307781 -214914 -827137 -79338 -536074 -584108 -186574 -610717 -455514 -351173 -887205 -429336 -606035 -339231 -624679 -992934 -631062 -591816 -495937 -291110 -343419 -944469 -614697 -855197 -178181 -778355 -724332 -127456 -600355 -289667 -488707 -540062 -382558 -645686 -896669 -949143 -540059 -709172 -428396 -770847 -262133 -86686 -716303 -145868 -476332 -856019 -387821 -362598 -143693 -579847 -459197 -947517 -823068 -62538 -61776 -34773 -734488 -962964 -784659 -975775 -1…
Output: -73420648

Example 3:

Input: 1154 750 -934657 -604217 -350241 -702510 -309072 -273665 -801217 -627771 -523990 -586583 -566990 -778452 -93317 -143528 -279763 -308027 -571438 -576255 -477708 -530506 -737383 -842472 -340482 -153561 -66516 -806731 -50377 -430485 -888494 -658867 -351029 -506384 -828327 -436535 -408052 -980676 -37496 -828006 -709523 -488218 -871580 -509737 -141490 -543568 -217053 -673321 -543935 -738816 -146460 -516995 -303088 -586877 -273449 -536628 -937795 -744102 -559762 -181825 -559084 -638907 -964448 -882734 -546783 -146095 -881926 -802154 -300371 -381680 -955161 -315902 -308559 -452864 -503070 -493517 -467764 -671392 -908102 -240030 -498096 -123976 -471213 -915172 -489940 -71784 -865446 -821250 -43392 -210481 -119662 -91448 -285157 -688464 -881204 -421079 -347784 -467679 -973504 -518353 -390639 -89473…
Output: -385138231

Constraints:

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

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