CT30572

The segments Fixed Window Peak Puzzle

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the island market of Coralcove; Xanthe weighs the day's segments 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 <= 1722; 1 <= a[i] <= 1000.

Example 1:

Input: 93 45 779 795 325 985 448 58 807 856 467 136 280 410 138 253 100 988 950 339 612 541 790 625 456 880 393 414 543 536 538 58 864 260 926 126 28 443 946 932 271 693 837 149 753 178 608 841 132 558 746 447 99 438 817 500 847 789 113 83 659 788 162 371 331 958 731 216 189 519 84 438 983 23 149 147 617 147 881 841 459 660 477 268 304 838 839 41 761 867 708 794 880 25 538
Output: 24534

Example 2:

Input: 1367 217 650 306 56 726 62 794 732 989 924 794 497 372 699 26 306 495 981 387 449 140 165 91 173 471 156 796 585 831 902 555 557 635 781 672 864 377 592 344 282 601 269 442 589 150 873 727 748 825 152 384 472 162 526 225 451 900 437 536 484 49 34 182 650 874 884 215 285 263 177 3 296 407 176 785 150 88 872 516 695 860 897 188 921 610 943 403 812 67 395 537 65 538 911 206 893 910 934 767 666 522 950 210 874 326 879 530 566 570 239 481 542 836 740 556 235 533 723 191 944 170 716 148 88 411 754 469 845 905 710 626 20 921 82 731 886 905 634 986 416 811 578 193 525 739 676 226 902 669 736 702 768 991 855 957 691 308 158 123 858 505 697 610 293 854 794 869 665 605 796 325 688 993 873 868 699 73 509 724 919 624 688 189 611 859 933 791 906 57 603 664 501 964 928 384 325 659 163 289 896 511 680 764…
Output: 128144

Example 3:

Input: 1622 1376 709 357 540 820 416 738 654 199 719 544 209 691 116 1 323 837 673 360 522 858 765 535 658 659 849 546 644 306 235 281 875 638 173 485 371 195 442 969 426 71 963 840 479 389 780 608 901 206 122 848 124 58 176 223 574 395 491 802 529 375 316 922 30 532 868 157 113 520 482 93 868 17 605 550 270 881 776 759 193 600 209 7 140 984 218 928 338 874 44 933 725 727 228 408 390 394 173 73 229 518 265 656 301 553 449 239 508 274 318 33 792 401 153 149 955 736 272 450 695 322 33 523 945 243 735 923 267 806 713 3 513 11 828 26 73 852 768 183 778 507 607 59 173 402 393 741 524 722 398 722 809 543 795 147 981 167 930 617 452 647 669 413 576 965 89 125 358 351 484 716 365 589 330 674 884 573 208 444 865 446 970 818 430 909 748 477 15 294 33 880 734 77 203 909 693 530 286 742 945 533 434 71 861 12…
Output: 682029

Constraints:

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

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