CT39059

Petra Counts the scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the valley of Misthollow, someone must catalog the new acquisitions. This year the task falls to Petra, armed only with the scrolls 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 <= 2150; 0 <= a[i] <= 1000000.

Example 1:

Input: 1085 898 3805 541318 191357 633069 463914 138906 30143 629221 284713 454181 357934 546652 826790 567097 656580 195967 442329 532541 296778 312052 887071 786479 401893 447881 450971 300762 112067 719406 745070 409044 580178 521056 894379 228201 151353 251424 246578 155785 219656 230767 713832 199769 69166 611527 523947 178604 910690 370378 62161 729102 319715 251386 936670 777465 262895 977398 841126 888682 977913 954508 742889 888907 15219 255791 873106 41499 958583 661978 724265 971043 709169 166833 366722 998662 182809 116210 169374 261809 346185 632079 363625 409059 288246 622248 989168 70038 736322 335429 51867 712748 829721 933162 955653 729438 165507 591014 739729 2242 984612 768429 441019 14877 238337 471766 991051 665420 734716 724912 116084 103592 246293 500356 106664 525522 96645…
Output: 433433414

Example 2:

Input: 685 49 717886 172510 567576 680543 598687 414064 625612 299311 891833 740822 437291 334609 239936 392898 160328 91732 261698 110354 494204 631677 422222 595563 894721 539890 800798 740628 693301 862756 892087 847046 800568 128094 368294 852285 716770 911330 297460 22540 287834 57278 14028 689676 653411 130675 106331 15861 848170 204350 9147 359332 476270 738093 690188 888070 497737 183739 431412 516307 670528 682750 247840 347990 144506 596469 430956 851737 181151 132354 171719 757075 862673 177000 973135 268186 12705 869745 355658 61687 210531 243825 194015 570683 96897 378666 642313 661304 437072 334205 618377 786764 803389 548868 387567 159477 471968 678255 74316 139516 266527 926802 834204 160058 455824 536347 75075 34056 605773 548455 356988 217420 834485 773999 388971 221141 559824 8…
Output: 19250703

Example 3:

Input: 1685 1042 371972 446509 567353 345459 587750 140871 108660 479921 377361 281458 309027 212935 477650 232425 199105 281157 347221 165671 567796 891459 840798 167420 162898 595588 11350 577715 715883 656201 850974 700996 351692 297970 482876 961283 447103 880495 306576 397786 100951 339674 94126 569853 574109 226181 410239 620103 24211 305193 301406 273405 822799 809944 308048 203226 64625 190231 63452 492798 359817 105599 33957 303989 142279 601869 669153 233887 405362 228014 720795 523213 555080 80753 851429 256941 998931 337812 80994 985230 711703 562501 373497 844737 270295 479684 575472 740681 125369 519762 141632 446730 856433 35792 236021 69421 144724 101891 470659 721737 636461 883159 746244 710817 289757 344940 266139 374298 796921 758165 378865 274445 850651 182407 92447 775238 646…
Output: 522657823

Constraints:

1 <= k <= n <= 2150; 0 <= a[i] <= 1000000.

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