CT50881

Pia Counts the windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Pia runs the ropewalk at the gristmill of Rye Hollow. Today the books show a list of windows, and the numbers must be worked out before sundown. 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 <= 3446; 0 <= a[i] <= 1000.

Example 1:

Input: 994 345 165 163 225 294 566 666 496 221 230 238 860 437 286 443 425 481 441 482 560 196 839 436 346 557 185 166 781 809 554 936 401 837 441 380 854 156 590 899 939 315 981 34 971 250 628 520 474 85 485 269 559 649 540 94 888 176 313 650 684 859 593 277 423 727 344 8 345 257 417 349 720 856 656 819 834 208 271 560 545 286 985 531 458 171 878 931 796 534 756 295 625 828 273 95 149 396 931 717 958 398 525 374 246 549 514 670 645 689 857 406 830 806 342 453 439 743 62 370 369 555 955 268 173 123 91 241 551 343 819 41 683 888 715 92 951 674 11 841 692 347 86 958 350 180 928 988 883 915 808 66 363 499 715 761 997 686 93 151 135 866 189 106 546 661 591 249 113 360 771 219 479 989 35 401 903 359 431 844 524 938 587 923 137 162 699 848 554 360 654 301 747 535 150 915 760 307 874 773 92 899 982 533 …
Output: 180588

Example 2:

Input: 3276 2080 738 88 262 355 295 860 432 590 391 129 819 276 114 490 519 110 681 534 813 839 354 556 994 530 467 564 797 198 531 914 435 724 757 480 901 214 843 810 38 455 35 769 518 515 296 443 239 709 955 655 311 268 584 186 385 643 251 64 408 273 436 732 948 938 728 782 753 61 186 446 885 929 354 759 673 795 359 539 963 888 91 45 960 719 112 796 347 811 325 706 490 427 777 956 774 869 443 913 644 258 234 636 992 290 45 947 838 590 349 154 712 362 563 79 512 855 104 837 422 436 824 248 140 388 328 783 314 631 142 975 436 62 877 146 741 263 166 552 349 902 359 639 2 177 601 513 807 955 938 776 911 951 116 639 175 715 100 586 886 799 128 135 852 518 468 137 135 999 836 575 184 15 458 486 408 892 699 98 674 380 675 764 699 163 587 240 990 433 317 838 306 913 506 548 350 442 424 14 27 298 429 50…
Output: 1039854

Example 3:

Input: 2116 1385 868 438 115 674 360 634 608 379 947 952 361 867 528 420 385 616 826 940 263 896 4 126 323 40 544 554 631 557 315 850 734 732 924 941 458 207 192 473 40 743 625 711 511 784 314 721 301 959 990 574 828 270 439 172 220 891 946 679 31 475 485 848 775 728 632 507 872 4 517 443 979 110 300 820 474 19 355 789 661 993 838 619 405 951 198 651 659 727 82 424 946 965 898 241 739 149 205 958 133 543 420 187 344 632 472 944 414 521 1 359 78 763 369 782 997 312 735 592 268 966 79 669 213 769 743 275 787 795 778 795 955 806 278 952 16 966 878 718 463 237 539 656 435 408 68 401 878 796 98 140 89 301 199 39 887 841 730 63 198 242 494 918 215 104 848 943 685 802 391 290 61 702 154 898 506 340 550 331 1000 305 520 891 843 146 434 349 635 125 951 598 37 86 790 993 286 78 406 697 116 448 138 144 882 …
Output: 706120

Constraints:

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

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