CT40315

Parth and the Calm Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the orchard lands of Applerun as Parth 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 <= 1931; -1000000 <= a[i] <= 1000.

Example 1:

Input: 506 230 -783991 -759995 -999797 -558424 -856665 -195213 -253968 -451209 -107524 -964332 -855242 -705525 -369424 -427139 -623186 -136344 -338722 -354587 -172617 -849388 -5041 -82038 -884512 -976248 -319354 -320288 -303792 -694277 -166126 -28427 -423254 -335788 -608496 -622896 -306024 -416851 -735657 -963520 -871221 -558509 -218485 -399268 -297554 -383528 -285590 -110396 -263425 -146145 -732939 -503736 -325447 -811084 -929400 -609542 -768582 -939024 -113910 -723281 -730662 -526006 -231254 -94867 -402740 -676298 -563325 -156426 -789549 -890778 -885239 -208970 -797344 -539216 -959274 -430961 -883949 -883213 -221269 -298690 -907152 -409813 -868998 -982486 -698509 -604913 -743179 -424529 -761097 -484167 -526736 -632742 -566478 -164061 -904400 -714829 -459376 -308372 -706607 -860885 -142330 -9581…
Output: -119012854

Example 2:

Input: 1426 1019 -170498 -183019 -312996 -47896 -238968 -265310 -942262 -89683 -934111 -432806 -584059 -777448 -786957 -948334 -658748 -545237 -549909 -57533 -325367 -350479 -828805 -473639 -505096 -820024 -995551 -470099 -472968 -526541 -789938 -404240 -470367 -203453 -846833 -981539 -582300 -150747 -740824 -147185 -18428 -690827 -614241 -617469 -382105 -462985 -474150 -952790 -933203 -640873 -344189 -777740 -946955 -437066 -106232 -181016 -442671 -581710 -85187 -839909 -346414 -363582 -889551 -872752 -176513 -611880 -137447 -366136 -344836 -78235 -649723 -210902 -490335 -823486 -688915 -187353 -436750 -528956 -558329 -942360 -667747 -154433 -766398 -650856 -526559 -519392 -592647 -423646 -989352 -451914 -981110 -673310 -532554 -20805 -660424 -97658 -375216 -295140 -695413 -29589 -81890 -379467 …
Output: -519983232

Example 3:

Input: 1449 327 -558628 -896624 -582685 -386064 -275343 -70987 -684213 -101511 -88594 -366364 -96790 -126280 -877217 -814561 -30842 -520094 -175658 -48303 -169521 -721294 -634706 -475060 -811687 -347530 -931540 -158759 -344980 -151001 -156037 -138090 -392529 -460041 -307942 -277536 -410686 -310027 -253935 -91857 -98643 -235365 -747585 -800009 -696399 -847173 -378035 -822090 -692570 -353625 -172525 -9488 -613767 -792765 -194915 -830120 -224655 -915995 -500415 -77014 -71241 -246912 -275258 -840919 -298955 -736933 -437970 -824454 -612379 -609068 -60790 -174866 -706990 -312879 -514896 -980361 -761111 -125114 -363813 -438769 -315956 -996311 -618076 -769154 -412867 -305884 -270280 -422393 -896308 -335834 -928633 -110997 -982766 -294232 -364732 -465066 -430799 -598597 -311771 -884170 -140509 -218289 -78…
Output: -170561681

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Parth and the Calm Window - MEDIUM Coding Problem | CodeTikki