CT32071

Ivan Counts the stretches

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Ivan inherited the kiln at the poppy fields of Scarlet Plain along with its curious bookkeeping system for stretches. 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 <= 3402; 1 <= a[i] <= 1000.

Example 1:

Input: 858 797 133 860 885 40 658 194 460 610 706 409 97 155 674 443 874 820 963 307 926 176 573 683 166 767 4 478 761 276 676 318 7 364 499 311 575 739 63 745 634 283 407 367 915 837 107 189 318 890 808 241 827 302 617 347 216 577 9 950 938 233 759 964 13 446 779 312 719 655 763 144 992 13 194 864 879 804 306 627 656 402 785 165 566 942 121 52 932 847 211 882 85 253 349 352 596 308 394 103 576 302 934 973 425 567 853 170 909 652 517 908 606 605 857 668 254 30 545 769 873 832 18 272 530 224 814 572 156 905 630 102 664 281 47 251 742 487 826 98 743 655 736 995 190 804 67 771 864 789 846 505 417 503 273 768 909 718 316 106 166 969 736 982 510 392 372 566 991 820 440 711 998 126 830 165 661 97 773 123 982 542 220 804 580 852 122 117 639 157 834 753 953 747 769 922 639 169 291 522 557 739 582 146 545…
Output: 398682

Example 2:

Input: 1342 450 159 680 99 473 529 302 9 121 373 893 492 699 857 286 862 142 635 299 864 541 772 241 756 562 456 668 729 96 846 291 904 75 117 483 189 778 111 185 983 155 694 76 560 365 977 547 514 69 264 170 634 637 602 833 737 650 884 822 386 424 36 284 333 583 604 272 557 875 667 18 469 596 419 634 767 6 107 172 381 488 667 880 488 889 735 236 411 545 262 642 506 34 151 735 661 201 532 51 790 686 116 474 419 621 707 84 167 864 213 870 147 991 901 535 805 24 983 354 479 332 218 689 981 275 658 444 284 980 935 645 512 59 325 471 318 311 575 553 794 359 44 892 18 12 82 156 337 353 978 85 810 941 95 772 731 173 296 903 643 89 865 421 825 748 177 293 563 467 987 118 982 234 736 592 997 214 158 709 736 166 295 103 654 389 554 969 90 966 737 763 977 698 459 298 575 440 855 980 926 432 540 546 772 541…
Output: 219060

Example 3:

Input: 368 29 202 836 963 26 334 307 620 66 306 494 34 538 654 395 461 198 546 89 11 260 672 519 112 53 626 177 662 21 752 395 592 331 800 606 327 512 842 316 410 527 215 328 189 872 429 480 464 943 345 578 116 868 969 149 553 174 292 435 284 403 506 680 986 137 659 26 427 910 106 248 647 401 637 667 351 852 120 355 329 327 555 712 596 972 129 903 366 986 872 268 510 373 784 977 517 6 901 706 482 952 15 527 965 685 1000 621 601 559 668 433 410 529 88 635 539 316 374 108 841 304 682 346 446 439 632 647 992 425 734 647 400 322 530 756 153 295 845 734 383 415 199 74 390 280 44 464 975 171 997 257 508 850 225 623 693 462 190 770 322 830 237 183 4 799 288 830 778 955 309 254 14 48 528 149 258 895 962 314 422 11 366 961 558 835 679 281 946 750 49 961 504 784 797 536 665 810 676 838 483 863 377 720 248 …
Output: 10251

Constraints:

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

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