CT49921

Porter Counts the panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Porter the chronicler watches over the steppe camp of Horselord Plains's stores of panels. A careful computation stands between order and chaos. 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 <= 2532; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1605 236 -74479 -770929 -283681 -41228 -922206 -191393 -523902 -92460 -653669 -321469 -607167 -826104 -751120 -26878 -587036 -758049 -275539 -308142 -410119 -430707 -799564 -272030 -287818 -171940 -352145 -400565 -946010 -622621 -522773 -465315 -86142 -51818 -173666 -348637 -479818 -909617 -554660 -653283 -422747 -299567 -350327 -245338 -959220 -55160 -106579 -394440 -943084 -417732 -390299 -516527 -877099 -209844 -423700 -923998 -380401 -981350 -565049 -818589 -835880 -505487 -571303 -463724 -323442 -741763 -698236 -789081 -311375 -694393 -572388 -23229 -610728 -253324 -732042 -667195 -380310 -410522 -681083 -453093 -606632 -788284 -988869 -22509 -83688 -885841 -973723 -107836 -791465 -269081 -143140 -942692 -866848 -910922 -347228 -643702 -71473 -634894 -140750 -578598 -963732 -26139 -85…
Output: -123934094

Example 2:

Input: 937 510 -206402 -788122 -938653 -245392 -874989 -195985 -839709 -381839 -429071 -764661 -414630 -157249 -921576 -985126 -720070 -859599 -791513 -110090 -789027 -170521 -187577 -985678 -765189 -357789 -358047 -450450 -195490 -382723 -383853 -234564 -578445 -413432 -159083 -482719 -428872 -954170 -132702 -653829 -887560 -641563 -277957 -735505 -387079 -671989 -755440 -138252 -701072 -249157 -266000 -819154 -489945 -755168 -259716 -538752 -689152 -827497 -443172 -533726 -600870 -733574 -733920 -695240 -84602 -458781 -961247 -640314 -957599 -993851 -83356 -611400 -684353 -391557 -346191 -860445 -573706 -530078 -841014 -794217 -288751 -235849 -173550 -295542 -759121 -759033 -637260 -732911 -504650 -248378 -348890 -117506 -500971 -17232 -362438 -440971 -441599 -301630 -40891 -174514 -907711 -164…
Output: -264213432

Example 3:

Input: 933 190 -253569 -187849 -740200 -113308 -87360 -41538 -264655 -926490 -794586 -705709 -310996 -182466 -820673 -996987 -302800 -230997 -507372 -587948 -42978 26 -566525 -600301 -220411 -484546 -871998 -834531 -387045 -62337 -65844 -14993 -548952 -609049 -319716 -203555 -196922 -226082 -27034 -486014 -410314 -42251 -844704 -202397 -986962 -899199 -584453 -84303 -222641 -576706 -22946 -108518 -813709 -317659 -9244 -852364 -596753 -156308 -809501 -18172 -475654 -899836 -628386 -255779 -868823 -758320 -159437 -96991 -886248 -55369 -438935 -296516 -141147 -522312 -202183 -295785 -58039 -894641 -862731 -179363 -19809 -564441 -273853 -464296 -733819 -825672 -324509 -143195 -330758 -48795 -860732 -47509 -105098 -98185 -35941 -490184 -378197 -228643 -577045 -938368 -708712 -998154 -550856 -862038 -8…
Output: -99566633

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Porter Counts the panels - MEDIUM Coding Problem | CodeTikki