CT51835

The ribbons at Fungaldeep

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the mushroom groves of Fungaldeep, Darian records each ribbons in a worn leather ledger. The guild wants answers, not guesses. 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 <= 3405; -1000000 <= a[i] <= 1000.

Example 1:

Input: 284 103 -751237 -152184 -967528 -610684 -604623 -541101 -740560 -33976 -351538 -870704 -938499 -579471 -358468 -839993 -292881 -883806 -249331 -276525 -48557 -563007 -411743 -373438 -462239 -676954 -748935 -522401 -185885 -302636 -824638 -188530 -812772 -887656 -469293 -433850 -344409 -819506 -127864 -773995 -9690 -425544 -81105 -729871 -850579 -320714 -696161 -218713 -490651 -740545 -244271 -129650 -255926 -33463 -154174 -332946 -844046 -655874 -271727 -410863 -492441 -289793 -713800 -820311 -90548 -98444 -43619 -726632 -427757 -274719 -994700 -632900 -425206 -347713 -368097 -265375 -370758 -68984 -23482 -911882 -196262 -295655 -392553 -533620 -648507 -826032 -214600 -244100 -703321 -272198 -94264 -892376 -920143 -473662 -230174 -420283 -231137 -893614 -92964 -956908 -644391 -399084 -4558…
Output: -53424025

Example 2:

Input: 638 130 -203407 -34272 -387629 -897984 -389385 -128995 -486193 -201583 -221397 -386180 -280141 -22196 -662356 -431093 -304631 -47073 -634723 -999966 -765757 -980510 -676758 -842885 -470813 -26974 -220498 -905452 -317455 -917286 -400790 -35155 -890579 -606964 -330430 -225172 -243797 -919079 -741501 -525996 -637408 -838560 -616013 -45085 -721428 -385031 -383848 -439948 -315709 -175885 -376144 -113883 -248830 -996383 -301177 -295800 -34423 -692264 -884409 -28825 -161834 -576319 -458005 -268487 -826952 -342249 -596340 -183663 -662749 -571501 -623597 -513016 -590377 -197353 -697206 -5321 -636515 -53032 -123062 -174675 -587131 -969044 -759641 -115766 -108135 -458822 -186400 -100816 -552765 -429782 -951877 -197496 -969257 -948480 -914022 -600585 -269315 -86175 -463883 -827621 -866740 -973844 -541…
Output: -69298747

Example 3:

Input: 1524 138 -732305 -97946 -589473 -461568 -286440 -385512 -462489 -481989 -858880 -212572 -371895 -868101 -548027 -170652 -938550 -500546 -801799 -695692 -319609 -489626 -196855 -350480 -704858 -215762 -343181 -338689 -205176 -216314 -235265 -500149 -273641 -706719 -714362 -27048 -421426 -102035 -484192 -932885 -779129 -473960 -919057 -679301 -537186 -953665 -73034 -295950 -385898 -394783 -85133 -490703 -15476 -121852 -701318 -579374 -361875 -339625 -51413 -806477 -898186 -22812 -869646 -776514 -828904 -635166 -790362 -567375 -879339 -209672 -438934 -664293 -567849 -28136 -270932 -737827 -557765 -537970 -93950 -612248 -121109 -15341 -692133 -54126 -53476 -974226 -529339 -554165 -754433 -959117 -516407 -47815 -542174 -198951 -548300 -101101 -940896 -20891 -368617 -942754 -737542 -542533 -6280…
Output: -74730748

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The ribbons at Fungaldeep - MEDIUM Coding Problem | CodeTikki