CT47641

Lara and the Calm Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Lara runs the studio at the fen lights of Will-o-Wisp. Today the books show a list of ribbons, and the numbers must be worked out before sundown. 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 <= 3589; -1000000 <= a[i] <= 1000.

Example 1:

Input: 2346 1544 -833454 -622513 -916535 -892832 -42259 -254003 -647160 -646690 -161259 -729416 -838015 -196262 -954245 -868003 -822972 -110276 -859249 -887673 -893148 -139017 -752716 -939777 -362295 -137033 -69977 -182580 -153259 -623224 -84430 -149713 -118378 -286063 -133343 -889206 -506911 -118059 -459896 -565711 -506610 -388245 -152402 -64416 -418497 -497063 -354180 -543145 -975763 -672762 -816643 -791605 -971518 -237109 -617264 -117401 -936014 -696705 -475743 -655720 -216420 -726274 -212091 -244045 -861378 -532033 -281995 -974535 -342300 -872382 -36837 -576323 -264472 -147394 -746300 -99961 -17911 -651763 -86988 -619395 -367306 -265202 -14410 -823599 -610991 -224127 -847291 -323147 -75666 -183868 -334376 -147148 -520163 -214374 -699261 -372445 -656456 -319182 -919671 -177536 -757919 -565139 …
Output: -775266022

Example 2:

Input: 2307 686 -452844 -334150 -721440 -378942 -22002 -565262 -911762 -581475 -423917 -323025 -324109 -514154 -878956 -363073 -837713 -707682 -253755 -947380 -457350 -644564 -253994 -420162 -340483 -239409 -200117 -428322 -682466 -273959 -263760 -94023 -496259 -585092 -716993 -345368 -413830 -692638 -551553 -979806 -296461 -245190 -684909 -965583 -617344 -380383 -176595 -207550 -103335 -703048 -427740 -401521 -802822 -445365 -978376 -699624 -912533 -80156 -282245 -918355 -914099 -264172 -596341 -180201 -716608 -974790 -976544 -220266 -74538 -624494 -450524 -18350 -444292 -472319 -238555 -97351 -48540 -837815 -817039 -608403 -63919 -492979 -507951 -845036 -300302 -445856 -154080 -15461 -195683 -838820 -422233 -399211 -528303 -551145 -495525 -39084 -901762 -422360 -280823 -544960 -286770 -773861 -…
Output: -352972403

Example 3:

Input: 1599 107 -147751 -784960 -530405 -886160 -84140 -768051 -943668 -744431 -257419 -701221 -35669 -674684 -532925 -376561 -477595 -508820 -141567 -29610 -67882 -927749 -525008 -633874 -704014 -138416 -341721 -321934 -623125 -909673 -530491 -291996 -116318 -51847 -563831 -428412 -389091 -63618 -311332 -686594 -198021 -979492 -336172 -347781 -23763 -805608 -455667 -653899 -505470 -73563 -550176 -22694 -26569 -49434 -133512 -957995 -643977 -997459 -842719 -505174 -753547 -854568 -289477 -156366 -648504 -491862 -443534 -234183 -809647 -966108 -372317 -753460 -790855 -757000 -611281 -696221 -106481 -251989 -249570 -946190 -765232 -744994 -907836 -173007 -660751 -633655 -266716 -627772 -649715 -202027 -67696 -20158 -43962 -229568 -54895 -237350 -55412 -941383 -350333 -350351 -243096 -315869 -30335 …
Output: -59604523

Constraints:

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

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