CT45616

The Wild Calm Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the cotton rows of Whitewick, Nils the dispatch writer keeps careful count of the ribbons. Document the rare sighting, every figure matters. 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 <= 1786; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1298 897 -780104 -942215 -935343 -203997 -502359 -45453 -652327 -65227 -331878 -602292 -555400 -351977 -89824 -511294 -178050 -463467 -865508 -156487 -772087 251 -237795 -653654 -109256 -378133 -14933 -852841 -843649 -411128 -260377 -894625 -760719 -60471 -935389 -561608 -66127 -727638 -328095 -21797 -120785 -487565 -186635 -203915 -274366 -164319 -477252 -403203 -278634 -366938 -967493 -322674 -807780 -596225 -383143 -755541 -73426 -264916 -102762 -358294 -763666 -264349 -582739 -767583 -476259 -925542 -633144 -791814 -358587 -625658 -994981 -585952 -884456 -462725 -622435 -573797 -132385 -674860 -289582 -815941 -520517 -654759 -116326 -112094 -354243 -535161 -313194 -581751 -26742 -848512 -26404 -846014 -450655 -196761 -659171 -560194 -185213 -674752 -464995 -410794 -72706 -22839 -774397…
Output: -446656927

Example 2:

Input: 264 32 -635935 -277338 -52961 -160344 -266282 -635387 -360429 -811772 -51037 -758247 -431408 -492262 -838000 -352295 -109091 -69367 -59778 -76565 -571519 -618596 -796785 -437041 -246214 -536175 -828279 -221455 -60852 -450211 -474448 -50111 -144762 -724417 -587328 -785132 -664030 -177791 -48509 -295628 -52365 -405699 -463128 -450308 -775871 -608233 -70506 -915532 -327083 -698449 -367533 -700205 -733809 -129870 -592064 -69503 -192216 -884167 -127435 -975580 -253765 -146161 -300119 -487631 -421023 -902207 -593666 -659726 -926356 -948820 -880749 -832230 -52305 -983236 -168564 -857697 -429858 -725710 -931721 -428481 -532972 -416703 -963767 -593670 -752470 -82570 -66513 -982958 -196729 -404012 -491025 -450862 -271299 -147516 -451461 -552431 -709333 -743014 -203926 -651236 -768133 -948897 -133425…
Output: -18505559

Example 3:

Input: 1163 92 -92805 -188220 -672117 -417385 -931262 -587175 -140437 -521905 -400747 -561161 -125433 -574144 -226599 -812514 -89016 -548215 -933002 -733998 -17354 -747694 -601753 -743730 -490578 -776577 -797298 -602916 -233338 -888017 -679106 -366453 -847694 -604606 -429495 -253328 -326799 -342495 -941707 -520840 -618066 -898683 -697069 -151230 -219460 -130059 -475521 -147673 -757483 -213674 -798367 -483922 -40232 -411171 -597569 -841823 -536581 -295101 -649039 -638012 -582636 -658286 -560091 -660926 -177747 -484843 -888336 -424566 -257732 -667355 -496071 -150096 -532586 -98705 -735654 -801675 -558844 -694826 -153059 -228304 -955811 -44356 -34201 -77112 -74696 -504692 -409971 -331654 -806976 -901988 -426145 -598040 -268578 -335274 -458974 -646485 -554681 -273639 -44270 -403092 -569768 -23592 -40…
Output: -58771511

Constraints:

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

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