CT40827

Wamika's Caramel Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the willow walks of Reedmarsh, Wamika the paymaster keeps careful count of the segments. Inspect the delivered goods, every figure matters. Task: Print the maximum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the maximum window sum. Constraints: 1 <= k <= n <= 3306; 0 <= a[i] <= 1000.

Example 1:

Input: 1095 127 916 864 332 185 647 689 612 415 298 358 575 892 516 8 372 626 13 843 194 612 739 718 450 170 297 286 994 449 729 142 372 363 203 108 741 635 21 868 925 484 401 930 812 143 319 544 716 375 461 996 109 963 444 586 26 121 840 655 6 19 218 289 793 555 827 971 147 108 672 745 574 870 182 646 294 566 926 817 538 544 850 859 65 225 56 206 481 581 424 492 546 979 9 225 859 51 634 656 58 861 455 944 782 412 135 126 760 92 542 949 456 833 795 203 576 905 111 516 3 665 166 433 857 920 84 636 747 806 195 101 568 704 413 100 802 670 948 250 645 726 157 348 849 849 789 145 71 610 145 211 571 434 537 984 622 638 147 208 900 401 594 571 730 27 551 666 719 368 298 233 364 945 992 184 656 476 923 651 399 141 211 511 603 371 333 46 608 767 203 703 818 924 409 983 112 903 517 171 464 749 607 994 93 8…
Output: 72006

Example 2:

Input: 855 701 601 859 684 242 977 170 368 256 915 892 264 405 880 215 96 104 287 551 820 266 503 841 848 901 110 583 331 519 270 629 406 643 168 27 590 216 309 518 848 592 701 41 301 114 203 761 611 699 9 211 618 593 291 510 654 78 90 658 306 189 834 512 880 552 263 251 320 519 433 51 961 775 1 784 491 405 400 451 981 180 5 876 606 656 175 60 689 364 957 357 267 106 560 139 233 763 44 963 192 360 686 102 582 701 103 977 727 226 158 125 408 165 369 866 757 650 773 298 854 13 145 543 354 790 949 442 648 560 370 920 376 151 467 6 562 604 543 683 252 57 680 227 990 66 750 533 420 373 965 13 170 545 670 883 417 799 785 855 989 954 286 16 393 571 276 755 219 588 421 325 484 410 324 299 30 734 81 139 119 709 248 568 900 813 73 828 570 683 795 886 295 726 360 574 677 65 852 150 103 761 590 612 941 275 1…
Output: 347420

Example 3:

Input: 2716 68 770 733 746 111 683 35 128 173 83 131 37 689 870 857 639 220 689 537 273 942 416 871 413 565 266 516 117 155 666 156 743 951 333 806 173 609 917 243 615 638 747 32 253 753 116 201 791 830 495 811 709 151 200 27 67 148 940 232 645 58 213 254 982 871 870 809 753 944 370 894 511 370 166 722 397 974 981 857 912 776 626 202 654 174 765 848 487 715 273 585 75 840 285 743 875 217 107 18 726 106 352 742 248 41 642 311 790 344 74 690 504 3 242 405 171 963 100 90 208 319 647 228 666 151 852 74 114 209 147 190 762 968 300 294 130 897 94 605 320 815 993 72 362 969 750 935 518 600 783 127 871 533 64 351 414 875 236 463 346 155 66 376 346 13 455 289 806 144 641 378 112 385 720 659 780 815 818 979 682 701 650 529 677 567 566 969 951 29 672 561 881 901 607 478 962 397 765 250 9 702 398 112 282 31 …
Output: 41318

Constraints:

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

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