CT38156

The Calm Window Beneath Amberfield

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the wheat plains of Amberfield, Eklavya the cartographer keeps careful count of the ribbons. assign crews to the morning shifts, every figure matters. 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 <= 3444; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1900 1477 -848755 -467361 -847094 -957231 -680794 -519900 -922171 -105347 -751461 -765884 -230153 -4954 -578623 -455519 -295389 -394958 -732045 -964883 -841033 -208136 -998863 -426077 -319209 -787641 -845558 -131750 -924017 -865208 -287559 -691986 -184292 -79389 -864864 -448332 -856689 -531576 -950111 -489432 -589305 -364588 -523465 -235025 -338796 -271820 -736590 -320948 -669833 -247793 -67700 -677232 -45481 -380376 -806593 -805420 -959146 -235410 -303617 -798988 -380619 -476070 -292356 -389681 -242616 -647588 -12075 -110212 -858466 -429826 -354241 -575920 -134395 -906061 -369009 -5467 -364695 -515535 -624166 -176481 -462058 -743430 -257800 -335026 -694042 -718243 -356289 -801435 -633815 -357776 -145897 -906194 -886757 -763807 -431467 -12249 -91030 -574821 -162334 -146996 -673965 -295220 …
Output: -753442553

Example 2:

Input: 2757 1728 -273286 -51495 -493731 -529857 -749761 -679445 -354163 -267945 -391233 -652835 -428783 -184168 -976826 -755525 -7918 -643558 -854457 -508144 -626198 -66348 -331879 -644902 -819307 -678953 -627794 -370899 -119182 -267731 -585913 -896836 -791090 -485879 -598047 -483817 -520162 -780349 -541546 -693034 -647688 -548004 -183302 -417514 -178898 -646782 -592496 -412095 -147734 -815598 -256824 -135453 -296048 -464076 -694049 -350258 -825230 -127394 -174868 -546451 -233411 -811454 -418072 -513026 -872127 -36403 -892347 -596098 -92205 -485213 -519275 -206776 -383464 -94236 -884731 -378939 -20763 -752995 -97369 -498455 -186519 -814686 -237627 -28961 -150368 -443971 -904839 -589356 -542908 -148929 -974612 -162456 -930586 -803198 -493573 -346195 -382518 -771571 -559305 -223600 -671534 -377600 …
Output: -894191216

Example 3:

Input: 47 29 -456496 -115685 -774777 -893702 -383613 -262318 -360797 -666913 -155114 -512356 -462241 -58856 -839058 -853391 -957465 -369992 -540147 -263980 -833414 -103335 -809571 -843937 -997443 -763768 -308435 -118214 -185870 -787795 -999548 -613514 -305633 -561517 -991800 -396641 -215233 -815705 -17688 -75495 -478515 -593059 -147079 -557254 -861262 -364297 -55654 -255303 -524971
Output: -16330886

Constraints:

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

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