CT54978

The Calm Window Beneath Pearldeep

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the coral atoll of Pearldeep, Milo the registry keeper keeps careful count of the scrolls. Publish the quarterly findings, 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 <= 2183; -1000000 <= a[i] <= 1000.

Example 1:

Input: 980 258 -824229 -912326 -456861 -639643 -512194 -803829 -735139 -222383 -32838 -620435 -620458 -309492 -615767 -634348 -799816 -36675 -722098 -249854 -867179 -883790 -913472 -631517 -877049 -296101 -797699 -709470 -404136 -48549 -546257 -135761 -347563 -964636 -664986 -332247 -177930 -708407 -50992 -474821 -119205 -244191 -577465 -355363 -434348 -537772 -42826 -827190 -641526 -13548 -29203 -955793 -888823 -786996 -703338 -326642 -719111 -275324 -563585 -738596 -675870 -422785 -671257 -173675 -273764 -375000 -897159 -573217 -659458 -665467 -179875 -244513 -758666 -288107 -839784 -696231 -414333 -770442 -480684 -998947 -572921 -843655 -919859 -848117 -184754 -842221 -575736 -555052 -504231 -194866 -330157 -772922 -291969 -848638 -838948 -350328 -771958 -210089 -576362 -581382 -983634 -421459…
Output: -135849989

Example 2:

Input: 17 4 -760499 -570505 -772624 -985743 -157890 -897168 -192679 -209536 -288255 -674769 -143852 -971338 -688385 -645219 -445002 -308366 -539393
Output: -3089371

Example 3:

Input: 1847 880 -243921 -52822 -541713 -168681 -267978 -869983 -719377 -777262 -418556 -101564 -894988 -993002 -771981 -446018 -295998 -618898 -317202 -785447 -371901 -799679 -891746 -10222 -686345 -761667 -583489 -121547 -686405 -920658 -172017 -199503 -147743 -31871 -142362 -133042 -267706 -826204 -33837 -871337 -153089 -386631 -502987 -787049 -48891 -773647 -335953 -31972 -763553 -220465 -977061 -443147 -559073 -671028 -691883 -756773 -631957 -406212 -684722 -563447 -863445 -860740 -440239 -789500 -608822 -131152 -980992 -391431 -524406 -674151 -208336 -766262 -116037 -767792 -505920 -998165 -200943 -528674 -957901 -36380 -685210 -342425 -396227 -930551 -364275 -721924 -273408 -137105 -771374 -110059 -755650 -728058 -339658 -653990 -532168 -507231 -208136 -474999 -760008 -832015 -773226 -72030…
Output: -453267270

Constraints:

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

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