CT53871

Tomas Counts the scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Tomas the clerk watches over the ink district of Scriptoria's stores of scrolls. A careful computation stands between order and chaos. 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 <= 1821; 0 <= a[i] <= 1000.

Example 1:

Input: 1064 925 29 374 167 636 713 98 599 116 168 708 218 267 268 594 759 578 730 827 879 562 128 62 653 421 579 330 888 420 149 505 87 32 506 91 413 117 811 950 946 371 837 607 46 397 251 373 356 387 93 100 833 710 125 340 470 825 991 1 199 545 228 233 586 309 270 511 865 104 892 910 575 647 951 464 420 171 345 394 135 432 874 311 806 366 285 606 941 870 660 926 51 705 902 208 642 980 881 284 150 298 37 159 155 557 869 403 665 411 828 334 40 668 241 177 253 756 230 838 266 445 894 723 428 753 5 969 350 46 823 823 527 81 879 665 489 466 298 990 801 464 380 381 29 551 866 540 654 404 747 88 903 257 255 341 236 580 518 699 860 475 158 424 443 572 933 601 92 319 663 199 106 462 350 770 663 350 900 513 18 445 646 329 258 110 829 999 739 618 656 674 510 874 32 377 414 939 320 33 304 343 5 939 351 27 6…
Output: 462528

Example 2:

Input: 385 243 260 190 358 915 111 865 309 137 185 444 144 499 492 493 234 339 171 463 951 96 891 600 790 70 164 100 557 80 395 610 571 180 926 412 420 611 517 285 433 589 944 231 43 982 449 397 966 651 819 603 881 619 976 122 943 625 591 760 788 99 93 220 351 678 964 474 162 848 268 797 715 20 288 971 203 369 129 728 822 760 906 604 989 462 568 481 240 205 378 922 321 384 843 73 52 639 596 186 841 990 610 161 704 585 673 774 215 780 274 349 532 929 580 759 321 705 938 375 169 649 939 538 345 127 896 737 37 212 127 162 465 23 114 107 956 100 791 532 585 415 900 721 838 796 360 802 357 839 320 734 313 38 144 955 682 141 335 779 998 424 561 316 249 791 7 539 753 451 406 70 24 222 760 224 784 650 233 898 569 479 999 709 44 560 413 283 898 488 416 756 516 969 746 404 903 195 640 760 344 15 910 740 86…
Output: 131520

Example 3:

Input: 700 187 89 156 380 473 410 923 286 634 757 623 348 487 341 73 66 177 395 312 550 872 208 110 300 570 383 104 132 842 769 389 465 661 634 942 574 193 946 92 811 615 708 506 240 347 209 845 624 82 78 448 625 180 393 152 368 950 357 759 747 790 861 278 946 602 351 254 299 160 58 411 470 262 842 944 325 678 61 486 217 896 115 762 859 795 76 786 114 498 971 709 292 242 711 610 949 803 577 892 710 785 776 757 664 506 818 581 244 182 226 358 916 922 132 170 855 0 863 265 152 165 207 531 220 831 785 409 524 906 347 408 8 145 474 669 32 159 816 530 551 928 277 125 93 170 562 615 834 204 472 713 97 899 624 218 951 625 582 383 77 598 120 845 720 623 628 104 921 210 618 870 880 167 971 32 455 921 421 187 230 197 677 171 553 819 732 962 396 811 261 493 713 806 466 431 127 623 933 631 429 223 57 624 317…
Output: 98630

Constraints:

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

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