CT46638

Squire's Saffron Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Squire found an old ledger of windows in the archive attic at the kelp forests of Tangledeep. The margin notes pose a precise question. 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 <= 1326; 1 <= a[i] <= 1000.

Example 1:

Input: 1236 84 557 496 967 815 848 217 637 620 321 966 146 757 374 992 955 813 404 63 620 672 785 148 564 31 530 830 325 467 368 426 681 385 137 578 59 626 714 536 753 326 307 754 513 281 344 283 940 73 311 160 262 933 10 79 394 21 588 753 791 958 808 396 189 483 497 594 801 404 386 625 450 118 387 737 224 800 463 18 192 708 398 782 182 127 968 778 363 144 590 272 422 256 68 246 888 569 796 455 419 920 413 651 209 761 19 293 68 620 720 180 409 4 769 349 458 30 329 410 982 108 32 877 897 625 400 585 804 801 670 430 793 30 97 24 669 525 774 267 472 867 362 270 451 300 555 289 842 609 66 321 143 631 138 329 160 512 560 756 17 666 607 582 667 606 689 345 492 653 414 518 311 667 805 293 942 584 692 972 952 210 312 79 515 271 359 486 963 901 641 837 805 461 203 376 350 197 787 705 61 532 650 330 153 12…
Output: 34743

Example 2:

Input: 1092 79 695 414 597 913 714 950 227 703 814 444 985 373 818 386 127 920 229 664 229 536 4 363 964 696 818 66 346 796 84 560 187 47 879 140 94 787 543 299 833 769 757 379 179 344 836 768 66 543 665 925 803 708 636 575 674 657 908 675 246 231 194 676 386 822 191 37 439 537 34 541 378 808 919 436 775 428 375 16 543 46 836 211 867 196 670 237 877 895 354 856 288 76 624 871 171 26 854 857 941 210 571 210 883 145 650 883 763 713 994 674 911 860 676 48 744 695 480 126 477 940 62 276 464 253 225 515 129 186 366 28 676 315 652 149 539 109 650 147 825 183 270 944 456 464 457 811 68 875 174 509 414 467 443 73 997 639 480 162 729 59 644 214 839 293 765 247 810 858 534 269 969 887 267 45 18 976 29 532 673 927 749 54 357 843 165 530 658 691 655 490 798 435 793 791 621 924 114 14 338 859 461 538 481 97 3…
Output: 31954

Example 3:

Input: 112 109 50 388 241 613 786 432 925 618 448 55 625 756 704 903 727 647 730 869 684 314 784 807 937 475 875 640 533 1 204 565 723 850 831 141 997 245 37 895 385 949 62 447 61 914 783 907 676 668 220 456 670 211 988 840 328 220 823 40 358 104 922 726 148 850 212 742 78 227 235 184 270 876 609 593 753 797 262 442 72 218 710 168 195 189 325 25 135 492 986 457 859 610 38 781 524 873 807 497 431 735 159 887 937 553 914 537 545 680 233 301 814 880
Output: 57663

Constraints:

1 <= k <= n <= 1326; 1 <= a[i] <= 1000.

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