CT29857

Hugo and the Calm Window

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the glass towers of Prismhaven, someone must plan the beacon maintenance rota. This year the task falls to Hugo, armed only with the stretches register. 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 <= 1744; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 1259 1191 499842 455685 -246312 84236 -464984 -952684 -6563 -982875 -117909 292421 -552699 -119632 911570 -250446 269438 116533 186382 -103714 934489 -406153 133123 -477270 -872041 286383 -379779 350097 -302967 144064 978005 -425014 -967165 -612137 428161 -238296 652178 -161622 -30113 -508509 -82904 -935933 -836481 -141956 -708851 -55327 414263 539607 394788 -211847 -904314 -12214 823735 485104 -994831 -419292 -473464 4068 -621247 874610 -893055 638957 62228 -557366 637331 -933510 960366 -661937 -71927 -208556 -58138 -329534 -80818 -383201 432161 188743 985604 511389 719086 -149697 -677572 -505343 -832071 851337 -482196 158475 15702 -547467 -595343 349351 -391371 577130 708728 734 98514 213728 -803238 -968413 795547 15648 488044 -965631 528831 -554981 824328 -129444 -672435 111722 -690005 …
Output: 6109007

Example 2:

Input: 1007 667 -20969 -503808 529844 281426 -841189 -239485 -156056 627142 409085 459660 674036 -93797 -920309 -650496 -298942 -298325 -553931 878042 692872 -199132 33747 18125 84309 -689312 -587383 319632 41281 -50085 162564 375935 -12371 685433 -394239 388470 -188766 551927 989710 -286746 -834071 -937047 406517 -214835 -945924 -979305 831314 403620 844607 -643586 144242 165236 49433 41611 792283 -166224 -182327 965463 710247 -524753 193672 -756167 530748 347354 -270360 -583381 -747978 998474 135431 -213222 -628727 -111109 430286 -774114 -688761 -633204 250962 -408133 569053 986414 696926 830719 388731 712284 -405532 -764338 652441 -663362 -876855 -330692 838401 -405839 614497 954593 -770517 -637819 -504574 -278111 382740 -67369 199497 450352 521954 -496798 95712 -979615 355648 -211821 -952233 …
Output: -16418812

Example 3:

Input: 219 78 296305 -273822 833301 -749249 140893 -134987 989664 -901915 893926 611243 -956103 470990 -324754 969810 805081 -598515 993080 516577 806326 -13071 546744 -296420 -758806 961851 294520 733739 -976698 155335 -225558 -76682 78871 666674 509509 -501474 -94590 699492 -576675 784744 584884 -783771 699630 676539 176614 563786 82369 -829867 831358 -173230 -749434 -774953 -7517 172876 -148853 -456325 -338899 -135942 -174484 339048 -307413 785208 -511199 14702 224223 70404 179025 -691770 964671 -173306 547550 -238113 -899767 -384725 -173731 -698698 996251 599025 -899882 -669012 -880111 885248 -38641 -189103 199631 485280 -496530 -873738 128792 674692 527909 -715278 -460659 -853210 -450446 647555 -314137 4517 -135118 -810406 -569730 -673214 5042 -778783 837643 -129932 -839159 -890473 187780 50…
Output: -12613270

Constraints:

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

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