CT34369

Squire's Lunar Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the island market of Coralcove opens only for a perfect tally of segments. Squire means to find out. 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 <= 2196; 1 <= a[i] <= 1000000.

Example 1:

Input: 487 133 832957 689295 279070 207881 636211 73086 218742 228523 433128 566740 499132 38487 492655 259436 449004 172747 332816 705041 834937 193610 221422 428867 215721 633292 197158 165728 474998 821433 450605 641283 927802 304589 46970 800634 584846 601588 964033 281883 583205 558421 409701 685563 926861 836792 934780 178574 277363 697767 952800 22694 442240 847261 861536 918555 792667 928510 866172 624154 424675 955101 261661 615619 146548 399267 433191 975644 816571 917532 414894 689131 250107 449049 950769 555459 903499 669267 598194 835276 772364 26750 973513 115687 636668 492236 287680 713069 216470 542413 764318 380017 921851 36692 472769 749095 18462 742158 418876 924592 636958 901609 313813 438760 689200 293458 982947 711826 955856 282155 369260 233335 913102 582670 103575 270541 2…
Output: 75226367

Example 2:

Input: 887 802 752033 596409 918298 974757 260637 878045 610912 678251 620815 542464 280753 124142 661552 867667 936376 439732 68450 421192 387568 470470 285963 624064 346102 441584 407556 420039 885945 721494 212633 475111 472394 777361 781136 155335 748205 966417 425039 83307 192830 44076 678530 973650 188524 585428 232593 150156 915799 724295 740448 406767 266409 19972 800130 540750 434401 75535 809760 756177 697326 587262 746709 319408 656337 428108 431111 552085 942752 163683 64625 139461 956746 673346 902265 476399 462898 958193 212671 666077 685062 140943 541587 676340 855133 299577 133040 101135 834476 645098 110560 428428 610637 694158 959415 969602 722138 71054 789313 934653 299928 498352 911352 256241 167368 770065 559506 724165 322976 940229 468904 248259 94591 213831 471656 39459 666…
Output: 400477095

Example 3:

Input: 1907 879 436433 634162 199180 560447 217348 454920 381903 410751 522443 842119 208530 512725 169590 883304 123072 616828 622654 82514 403656 755871 776939 646229 165920 775236 51897 613921 115492 971733 424768 379990 367958 456133 461843 90686 734518 652235 818874 750647 581375 4023 804319 75932 657864 539895 55999 573902 937475 218933 350649 308095 966473 363531 724546 374635 14752 335367 450958 127067 935905 247901 600995 658777 800627 5671 242207 834618 616587 143429 906335 377261 734144 728698 496178 287716 399875 616358 347328 245681 868699 139980 123423 243398 471871 416728 270911 793954 417126 576811 453302 369840 616106 241661 218663 705849 901256 380063 758377 386542 961154 708263 384020 211038 66993 572654 139745 109465 936939 714965 274868 490631 553027 190190 821035 263147 5127…
Output: 446803509

Constraints:

1 <= k <= n <= 2196; 1 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Squire's Lunar Ledger - MEDIUM Coding Problem | CodeTikki