CT54184

Manav Counts the ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the granite steps of Stonehallow. Manav spreads the ribbons records across the table and picks up a sharp pencil. 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 <= 2628; -1000000 <= a[i] <= 1000.

Example 1:

Input: 810 519 -12302 -536364 -678949 -749476 -917124 -861000 -327296 -761467 -74098 -410453 -33745 -648087 -579090 -98676 -453558 -332439 -722578 -634944 -382545 -441935 -219394 -537517 -15472 -514379 -972099 -254514 -95571 -792146 -973513 -25471 -601250 -205540 -184697 -727121 -957081 -268958 -43147 -961092 -478091 -82248 -910625 -56325 -475277 -873499 -423945 -809563 -494704 -167519 -561721 -910827 -431551 -441422 -869170 -31268 -481356 -463365 -442765 -466663 -606481 -445979 -725875 -719167 -544988 -84311 -113267 -666405 -204429 -325716 -565613 -667349 -435947 -638671 -210458 -260898 -46854 -503736 -670719 -290742 -908556 -566152 -944452 -950930 -458392 -262336 -794736 -541536 -688937 -822570 -162636 -232189 -59595 -843088 -155105 -157830 -759277 -998000 -946763 -159334 -350079 -792234 -20805…
Output: -272904058

Example 2:

Input: 308 74 -883555 -17051 -372206 -667392 -965715 -354321 -31550 -444147 -275356 -898812 -207329 -428435 -997856 -333503 -139614 -628430 -185641 -652604 -260786 -393272 -848638 -73007 -880690 -660939 -909837 -65578 -999629 -454304 -781105 -208200 -84916 -249675 -107696 -80227 -19100 -925496 -883558 -328609 -776832 -745950 -62903 -676802 -483624 -280564 -91370 -94153 -986287 -198983 -782278 -665753 -788038 -885920 -137786 -367536 -425792 -573771 -663047 -686465 -196195 -296686 -854853 -845366 -654441 -435026 -762327 -507260 -436745 -493833 -850960 -476322 -951536 -3819 -596012 -300246 -962878 -511683 -652120 -110776 -390258 -752377 -568812 -313024 -53528 -228342 -599137 -670282 -863161 -526768 -547608 -890954 -399861 -245825 -73419 -525477 -509736 -613299 -963618 -336194 -267825 -970819 -941563…
Output: -39000658

Example 3:

Input: 1894 984 -268780 -369308 -539038 -26942 -274356 -46383 -838660 -876160 -465682 -274077 -660062 -760316 -749036 -974710 -585704 -617628 -562053 -710507 -785575 -340900 -877903 -661967 -550766 -840036 -622553 -223989 -268801 -770073 -385484 -610583 -622374 -969057 -880692 -14759 -180443 -694107 -677 -480188 -182034 -101228 -661246 -371588 -950449 -226196 -236457 -925132 -87993 -560156 -559780 -34816 -979150 -965280 -584371 -409337 -895459 -841558 -863830 -412169 -996571 -832629 -248170 -770490 -181064 -139823 -911262 -908771 -329126 -580739 -569747 -519207 -41770 -613019 -705007 -336356 -65717 -629341 -985626 -658406 -617533 -421163 -9481 -452016 -244401 -583001 -776340 -971812 -94899 -712578 -47873 -296563 -813511 -203672 -485364 -895717 -608614 -45966 -66726 -679297 -235449 -402779 -783411…
Output: -501795644

Constraints:

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

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