CT42159

Librarian Counts the panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the observatory of Starfall, someone must map a faster supply route. This year the task falls to Librarian, armed only with the panels 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 <= 3392; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 127 83 207801 -73696 617140 -581092 -933205 686643 -147701 -783410 672988 -69275 321762 981908 146430 -506334 -745493 46927 102701 -548184 345276 -504998 115018 352578 -509641 -446424 555281 371464 551040 -695726 -211176 590370 101223 -916448 -684560 -980507 237302 245761 24618 15445 735493 741243 300552 167246 -52766 39770 43595 462265 -409174 -875993 -514216 463516 570351 610895 -769660 236533 -755122 42812 -332159 -620151 -657807 -990571 -614261 614980 -968196 -283535 -333674 143201 -90476 -8336 507209 -352726 477625 -34706 -828030 393885 715845 688276 -914138 -828381 -397801 -52008 -917910 592495 469480 752099 254300 -194340 -302743 -549116 101228 -215324 -852112 -837785 -744390 -668191 -860074 -216751 -517988 -227960 -978177 826100 909560 -169086 -748136 169055 180973 -44982 -381789 5…
Output: -11531441

Example 2:

Input: 3266 3074 547305 -74751 283670 -602371 656897 -367079 -808225 409443 195414 -878896 -739064 503240 -642327 -393311 806175 968509 615770 147226 120958 -546820 688318 672197 313970 922353 -859593 588213 -488760 -714280 454400 -101930 568063 871677 -606605 -690307 837120 620996 418057 -599183 829167 -846433 126800 401256 -332519 -51417 555609 -926314 -552708 -569631 920290 -788888 276989 746831 -279843 -920277 91187 919908 -268043 276256 229428 -568512 319998 985979 -408966 -302514 339631 -52845 723108 -68977 856458 -112342 -381407 -897234 183534 -983973 44089 -537379 4805 211326 -974051 853065 -793684 779387 -115860 -772873 -855692 206232 -716482 679115 -236700 554507 234164 652946 891264 921660 -549792 -212545 -884570 554386 632926 -811781 -275915 -618460 943219 -356925 82520 -484470 954867…
Output: 21455822

Example 3:

Input: 981 590 324940 -998419 -774949 38049 5598 341843 822172 567050 707605 -454593 981969 213214 -224570 848651 -295517 -47528 -909527 -202573 -359891 166524 705733 -176146 834835 -307307 -458863 104921 903971 934570 109071 -195949 740890 -810789 953225 -552600 512564 530019 -175201 172924 -37140 871452 629236 294677 -772235 -268442 311023 857967 -759885 -609323 850 -71505 70091 576754 -739095 -30939 154833 -87564 -141911 668621 -165415 164917 434333 123420 -226613 469372 -687820 209845 724999 862831 475797 -391121 -917771 -798072 -17501 694739 19441 417237 607936 -447483 -500811 -349220 910277 -908534 318746 106634 541533 -354731 -422936 89222 673882 -34757 -971178 935838 667523 -426810 -712172 209552 -932099 802294 471812 689896 -684838 -432900 -265196 -173664 -531225 -919477 538618 26636 620…
Output: -38102891

Constraints:

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

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