CT34875

Zoya's Ancient Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the thorn maze of Bramblecourt opens only for a perfect tally of panels. Zoya means to find out. 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 <= 1625; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 354 198 -974321 -221595 -46914 -66607 -873747 -78694 -436166 607025 -279007 826075 122865 576318 418519 27096 995849 -439189 -811333 544725 988025 -314440 -434267 843049 523810 767746 -333210 786078 -770867 661601 -123529 -614095 -89663 89584 145122 925902 128975 742777 -541660 796440 550625 -939490 -307645 -952357 31380 -126220 -802080 380843 487276 -348158 935029 -497291 594071 723393 733900 763735 -586881 -865295 -449083 447223 42818 62951 -824908 -897558 -968090 -645893 303768 -985508 -246928 918152 561456 -770239 -223637 -592632 801192 490284 390722 964204 1267 254475 -580075 784569 136883 -115389 -774593 864849 -811507 526570 -450111 -55086 -249953 -410337 491852 -3559 -331876 19093 -506589 300848 -504476 641566 -455351 -981665 -628196 511477 -700289 393094 46049 657196 57286 365829 …
Output: -13461389

Example 2:

Input: 1273 491 -528860 -134884 -499630 495271 554486 721524 250468 967499 -563498 635512 206400 68927 166033 -967033 -222819 96009 -580205 226190 -564737 -116576 -296083 299226 647439 -936686 -216718 -812151 29493 -964157 540318 -327645 725157 -125269 353110 -954507 135911 -917939 -715752 -372790 -68834 906192 -812248 798522 301925 297257 -108199 435055 679169 -285367 907667 315526 812458 -832058 699476 911679 288285 -838128 643662 -773657 -93548 327706 -353519 347066 -387930 -841120 -820309 -886193 -107674 -541674 -596192 148374 241182 124278 525707 -291485 597857 -216613 240292 953530 -810646 353300 707578 504366 -557280 933032 -695201 339585 467926 -642802 -792894 -215631 215101 17696 478981 -797854 828878 940554 -224112 -607183 -277896 542672 -888340 -309008 -783013 -726107 483393 369142 -86…
Output: -4443377

Example 3:

Input: 1412 772 -653002 -479771 -376611 77618 -212439 -584865 -94931 -611645 633498 -730689 150508 -846880 324717 -427003 -287190 -768197 279964 -418235 -556597 44846 -264308 98730 -701943 941709 258469 -633163 -85154 702372 -841400 839075 -618332 194780 76160 993059 276056 -993972 -221372 -161739 -466360 -337975 456293 -58568 181189 463763 -342877 -738826 -55061 762372 -869172 849819 -52338 -439352 69630 855237 160147 -719050 106172 130685 -477103 -876399 -817931 778475 320709 512786 400656 203131 24600 -262611 318017 -377633 915095 -927380 799234 -257745 715099 578390 47268 -891570 -881563 -350105 -989794 -484587 -420516 643628 -521086 419313 47962 -911890 594164 904229 503209 -116318 348871 -660808 305443 -2620 -277763 -406348 -285087 582676 -172049 298192 605214 195817 417296 728998 -263492 8…
Output: -9767982

Constraints:

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

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