CT43046

Tanya and the Calm Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the windmill fields of Gusthaven. Tanya spreads the scrolls records across the table and picks up a sharp pencil. 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 <= 2841; 0 <= a[i] <= 1000.

Example 1:

Input: 426 401 385 631 472 194 225 704 682 621 480 569 706 961 115 539 598 730 451 519 327 807 79 923 34 465 199 242 712 388 245 573 163 219 297 657 26 234 813 295 458 764 459 651 377 430 551 413 644 189 946 193 170 544 333 341 820 28 355 261 606 706 809 365 96 366 755 664 236 330 402 15 353 909 456 330 986 312 938 904 36 198 854 268 851 996 695 307 669 506 811 800 644 489 7 853 66 959 472 378 790 523 759 515 680 729 978 688 282 118 730 395 949 951 241 869 580 204 98 696 20 281 930 8 841 537 109 39 166 415 56 575 273 730 89 889 785 693 489 866 28 385 605 79 436 561 40 338 993 564 961 361 938 468 150 978 277 474 115 544 717 277 3 433 708 651 228 177 17 228 677 916 613 670 300 266 72 670 627 777 590 304 112 262 998 341 170 109 197 889 104 814 205 756 6 457 509 225 338 454 944 96 748 742 938 652 606…
Output: 190249

Example 2:

Input: 183 152 606 89 861 313 89 236 395 114 479 252 135 691 382 492 751 244 804 443 751 675 232 39 897 597 99 54 773 94 145 890 447 730 638 737 236 449 921 108 612 387 817 184 715 727 430 282 64 851 157 625 728 131 340 896 693 386 569 983 548 831 497 235 976 733 437 593 66 660 221 908 197 116 146 752 174 697 149 123 926 587 467 6 629 396 987 500 290 864 681 118 625 815 972 479 141 876 29 704 982 805 637 295 774 982 363 652 551 570 966 554 427 384 251 886 536 817 458 20 722 413 397 855 877 954 93 19 485 486 683 178 398 216 684 30 605 316 392 78 441 451 221 87 991 702 842 758 224 806 979 529 232 496 687 339 683 530 167 875 912 828 545 911 805 154 838 30 451 488 378 732 72 388 462 923 663 133 706 138 786 564 194 895 805
Output: 76166

Example 3:

Input: 324 93 59 900 134 492 775 957 757 471 84 532 990 876 840 168 319 164 149 641 90 453 840 737 883 846 583 322 327 593 968 183 135 902 113 91 404 101 311 581 698 763 34 878 20 418 449 996 702 825 959 993 49 746 366 285 264 793 889 481 513 906 351 113 627 98 503 460 657 4 737 330 0 362 302 133 663 811 611 580 878 654 948 457 170 216 29 983 256 323 275 497 114 438 875 895 773 463 282 812 966 503 584 648 845 65 3 41 48 196 413 244 644 189 417 589 90 419 443 493 280 989 788 547 14 398 68 526 478 386 564 83 303 621 624 312 810 126 89 180 105 504 406 634 42 596 354 560 900 727 621 743 263 375 784 978 123 447 318 100 145 71 676 745 258 376 667 550 236 877 954 299 954 124 149 598 783 314 650 371 874 442 496 436 91 495 18 830 987 594 474 904 268 401 602 144 663 420 902 174 725 454 804 741 651 850 881 …
Output: 40689

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Tanya and the Calm Window - MEDIUM Coding Problem | CodeTikki