CT30483

Leon's Caramel Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Leon inherited the granary at the seal rocks of Barking Cove along with its curious bookkeeping system for scrolls. Time to make sense of it. 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 <= 2184; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 835 733 -285891 544403 -587732 -752160 -551739 -611781 738587 -597944 279635 -594456 365981 14974 129453 -835823 -178932 684200 487808 -781830 330694 479152 -96293 656162 144216 620199 559756 -880271 -557184 135 -224203 -885498 -766206 174169 -818220 84928 -475596 335920 -39257 594439 8912 -354777 -906446 692829 762656 832501 869635 611509 -784535 -918652 223941 -69054 267197 531524 -800408 184087 -731250 494812 568021 636101 -10774 49146 429360 75696 677979 -969488 1423 -548241 -433555 -213686 766075 -104229 -426996 -488053 134 -424700 -56604 -829963 -329280 119660 -652119 107875 -331296 549046 -638115 -101765 -973164 730975 571351 -706146 -817177 718265 -416518 428444 358669 76379 508296 -970994 292827 801185 938081 45644 -32927 733904 549423 -250203 -997029 -239832 -831645 970865 -67713…
Output: -11977348

Example 2:

Input: 547 7 118648 752766 221584 207656 17166 532878 353432 339590 918243 4837 177009 719271 23189 455486 -724533 819575 -453156 -525665 -267316 410816 429083 -635300 394657 -317037 104140 -145569 -335024 284401 93532 737975 -816753 259427 -8000 253156 307417 -515373 -798747 -768838 -669324 45148 261008 165678 475712 574398 956476 -966798 -494101 -351469 -334458 -244699 523410 621932 885076 -51128 573356 245640 867592 -880942 -71625 -148446 981287 -733599 594957 -824567 887174 -76607 -439878 -535879 979581 -766298 956415 725588 111609 -988533 -141485 451536 -269531 -456231 932723 -862842 -956290 -812610 297269 127435 -37786 -870887 -44127 -396181 998699 -682635 982870 364882 -866489 698288 625880 -431157 -678501 -208061 129609 804183 -167188 91957 -95087 392364 498083 -936674 466745 382965 59461…
Output: -5492636

Example 3:

Input: 424 238 516198 751093 799166 -413237 -376823 -379500 550145 -65601 995438 810770 979292 -309440 -700853 -993229 -433172 551564 818387 969407 -167290 -439039 -368750 -329141 663071 476571 638652 317669 506861 -890861 41507 106064 497977 625705 810672 699843 -435520 401129 -437987 -763139 -843969 893754 443779 498586 -631336 -20146 490457 -420149 319709 338666 759786 -856599 -610658 -514353 131607 807126 -786590 -758887 -786154 628105 312914 -41361 241060 -710300 600259 -44027 -12086 161288 444337 -193063 -687924 333149 -974042 -190309 -145536 -799697 -281099 -466206 589317 -100853 258278 863002 -769958 -583501 298371 998498 -890743 -770863 -341364 357803 -615146 436216 437299 270934 -395084 920715 767923 43819 967943 -11489 937235 -748956 -714427 -367320 109956 595604 821269 473963 -271936 …
Output: -2102399

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Leon's Caramel Ledger - MEDIUM Coding Problem | CodeTikki