CT56662

Hestia Counts the panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the pine barrens of Needlepoint, someone must prepare the guildmaster's brief. This year the task falls to Hestia, armed only with the panels register. 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 <= 1524; 1 <= a[i] <= 1000.

Example 1:

Input: 967 421 469 80 441 950 120 688 331 865 682 253 856 470 475 363 806 807 937 68 30 787 537 211 846 737 288 513 193 645 602 543 35 640 570 665 749 916 710 680 76 538 393 338 289 329 103 701 941 139 837 216 838 398 91 210 575 656 478 680 855 641 232 883 654 846 564 107 364 199 337 110 246 651 821 845 412 128 227 863 666 178 107 850 587 286 885 134 347 938 804 598 966 97 655 465 638 875 353 132 978 744 922 17 818 333 508 898 157 996 621 801 629 981 710 193 912 599 338 347 245 853 734 483 741 574 473 623 756 472 887 230 725 276 471 518 907 168 236 660 869 237 383 329 670 801 383 347 314 232 97 215 131 875 869 988 677 934 476 501 53 950 705 897 221 35 81 411 209 296 404 790 464 941 291 971 895 455 150 458 800 253 740 129 461 692 936 493 694 658 482 856 53 712 457 964 526 332 791 189 893 326 639 4…
Output: 220189

Example 2:

Input: 291 228 263 493 675 266 15 195 867 545 604 521 542 749 723 707 456 363 691 150 693 873 963 750 75 659 503 333 755 616 661 791 278 646 87 740 78 4 932 555 569 577 849 840 203 302 881 739 148 547 581 740 282 638 585 255 358 235 542 818 857 109 150 37 838 913 625 1 884 581 397 350 698 531 654 698 919 448 697 934 834 491 438 530 712 601 732 821 902 343 735 823 546 30 820 141 786 119 569 239 723 194 630 153 402 92 187 635 82 680 497 401 696 592 590 816 507 531 668 764 532 455 154 536 714 560 384 720 961 528 976 253 927 225 577 315 531 487 481 401 352 852 145 266 764 446 60 940 112 832 704 718 610 961 990 711 326 371 671 608 487 997 27 615 844 67 56 555 922 184 589 116 635 183 105 235 467 425 888 32 213 568 863 127 919 751 894 35 928 223 7 757 306 132 966 10 509 69 928 871 627 978 390 853 779 99…
Output: 121043

Example 3:

Input: 70 14 251 559 467 935 44 775 214 591 179 582 640 15 193 166 817 261 295 24 286 997 243 866 120 171 261 7 348 920 450 35 643 769 75 871 114 242 425 526 71 706 227 452 32 12 458 322 831 96 653 584 710 387 36 873 762 933 512 4 995 369 519 122 612 937 428 398 968 18 880 772
Output: 8432

Constraints:

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

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