CT56891

Theron Counts the stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the crane marshes of Stillwater; Theron weighs the day's stretches manifests and starts the calculations. 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 <= 3486; 1 <= a[i] <= 1000.

Example 1:

Input: 2610 733 915 709 18 13 679 98 276 798 599 426 200 206 631 318 934 382 500 706 71 57 687 337 724 965 354 291 417 634 45 48 936 74 740 215 238 166 220 348 504 576 46 413 481 725 15 864 825 581 411 300 360 686 696 188 116 16 864 166 176 104 135 447 675 105 549 922 737 678 911 86 74 403 552 857 1000 734 351 323 937 27 431 647 718 842 734 112 729 455 782 527 848 225 15 844 222 853 830 236 855 523 435 439 646 992 402 835 122 261 537 918 860 712 799 454 267 575 676 933 127 311 325 234 131 379 112 269 627 110 138 876 72 163 381 155 570 48 472 344 859 931 775 517 10 566 270 311 124 787 484 546 441 923 722 918 714 283 472 235 228 888 963 465 166 422 988 353 990 984 824 392 656 106 885 837 829 949 926 353 225 625 285 291 631 130 359 504 99 32 799 125 851 627 655 683 299 312 148 739 974 878 403 667 95…
Output: 378672

Example 2:

Input: 3373 2179 880 869 543 172 493 538 803 868 653 514 979 672 774 69 700 157 65 545 874 29 940 464 134 342 268 652 676 986 43 122 30 420 904 396 792 850 166 536 739 321 386 428 397 41 119 449 890 171 676 370 405 921 740 195 655 441 177 110 763 69 725 988 721 903 70 795 616 244 466 640 82 283 864 53 194 850 905 252 23 267 105 90 563 333 699 130 901 167 497 933 241 278 877 988 959 471 594 577 988 317 404 295 657 186 691 194 731 793 882 681 163 529 29 379 255 274 551 187 342 249 343 46 45 46 267 953 811 819 173 833 886 392 920 573 132 539 270 468 464 682 807 671 591 169 270 797 473 332 96 281 420 437 190 965 566 493 245 145 661 654 829 437 8 565 939 129 788 133 178 159 922 439 224 832 6 531 428 863 716 728 927 541 408 202 24 802 133 121 339 830 295 94 339 921 934 940 878 597 803 928 870 265 264 4…
Output: 1112529

Example 3:

Input: 2701 986 519 714 285 31 530 216 92 795 397 143 898 123 602 241 785 955 652 761 573 366 776 555 82 590 891 382 445 262 965 743 698 47 249 493 41 534 283 764 79 555 139 53 36 920 854 615 992 747 164 350 956 832 202 162 280 36 395 92 455 358 461 607 25 837 418 107 817 10 324 614 876 225 668 19 882 22 24 446 714 118 423 40 800 365 874 360 199 6 117 911 711 397 746 77 128 457 433 245 124 259 202 995 160 369 974 503 577 823 481 285 288 833 649 815 733 418 812 233 318 810 723 264 552 63 27 511 710 84 145 809 4 863 323 256 488 698 44 764 325 471 384 428 487 372 590 743 731 734 905 865 648 519 243 425 10 193 618 613 631 393 4 237 645 27 697 694 146 165 311 574 114 542 6 253 927 619 229 671 143 380 677 6 45 618 595 30 892 24 844 761 282 283 433 636 304 859 137 409 918 963 740 732 842 447 241 153 28 …
Output: 510195

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Theron Counts the stretches - MEDIUM Coding Problem | CodeTikki