CT32223

The segments at Skyharbor

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the floating docks of Skyharbor, Kate records each segments in a worn leather ledger. The guild wants answers, not guesses. 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 <= 3992; 0 <= a[i] <= 1000.

Example 1:

Input: 3350 1635 487 628 714 250 347 88 81 452 638 961 122 998 351 759 212 817 906 637 968 999 700 237 713 740 620 209 696 367 865 591 781 184 285 213 253 109 887 566 771 190 155 704 759 217 27 605 309 359 576 845 24 274 482 697 427 344 216 937 967 826 723 568 798 872 391 230 694 209 644 603 671 714 754 659 710 639 129 786 738 161 330 303 399 320 577 206 479 347 707 514 360 228 532 901 928 841 356 56 145 190 886 706 388 880 653 411 84 255 201 898 12 493 75 239 295 880 933 708 543 470 685 982 757 101 314 34 906 467 816 280 208 163 792 775 0 979 122 385 952 497 765 330 719 300 584 682 197 427 699 671 62 909 493 656 154 373 291 131 766 10 586 878 217 790 130 666 721 293 637 211 510 409 502 189 812 876 310 107 874 593 298 72 95 411 607 516 150 282 567 187 974 114 405 919 629 102 100 981 682 361 873 5…
Output: 836755

Example 2:

Input: 1065 172 825 676 605 724 840 157 831 140 408 48 997 838 511 689 830 242 622 961 210 587 676 431 905 530 926 129 802 420 788 907 65 23 8 889 28 35 701 772 43 140 850 22 472 364 298 104 512 888 738 535 129 191 976 639 252 328 389 357 669 774 622 387 739 363 30 884 879 814 38 673 827 756 350 680 28 638 352 465 276 843 957 851 171 538 826 598 891 564 153 833 459 54 463 797 332 308 504 515 584 12 449 214 676 856 537 187 38 385 815 667 135 920 552 753 713 970 165 996 878 77 453 982 981 540 589 433 43 22 850 485 234 534 951 106 420 668 178 946 639 223 355 942 660 198 803 32 931 551 870 388 345 803 124 578 609 122 302 479 124 751 204 795 951 757 170 338 460 277 254 602 757 512 999 376 61 642 101 262 21 205 910 800 95 862 391 757 485 26 162 602 16 584 355 899 602 861 654 170 427 274 715 82 462 566 …
Output: 92501

Example 3:

Input: 1061 1030 251 141 86 484 954 55 296 970 609 833 699 85 170 977 377 207 685 479 240 943 16 847 859 397 295 787 50 267 207 866 418 297 220 597 417 89 454 855 807 226 935 350 337 781 125 199 695 93 537 922 783 291 107 176 808 231 728 254 983 686 820 136 123 742 5 414 418 555 789 241 540 515 735 430 245 287 814 590 819 999 993 737 394 141 587 100 216 152 143 973 898 452 709 856 172 212 680 606 695 136 345 728 150 123 497 34 409 447 847 36 565 10 253 985 917 475 424 649 158 409 241 924 792 468 765 38 207 23 70 961 502 129 50 767 128 211 81 444 473 912 502 329 181 754 741 667 773 980 549 493 591 708 225 687 586 46 396 403 451 355 245 60 899 78 828 618 379 437 955 404 592 153 88 955 4 119 986 148 30 241 213 529 507 6 542 922 762 7 41 4 726 860 468 573 781 492 90 320 760 183 534 211 330 568 735 47…
Output: 509864

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The segments at Skyharbor - MEDIUM Coding Problem | CodeTikki