CT40449

Bishop's Windward Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the mulberry rows of Silkmead, Bishop the bookkeeper keeps careful count of the segments. Tally the donation drive, every figure matters. 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 <= 2040; 1 <= a[i] <= 1000000.

Example 1:

Input: 1906 246 676803 358506 435908 300333 238954 864245 935543 701796 658337 345534 950603 927909 374920 879297 468357 877060 936259 555659 706693 921683 744345 29536 588180 715457 69937 239239 178807 740676 468565 807387 571327 202263 313006 510126 806645 167464 330709 401277 311831 802214 252689 352646 234091 326808 796295 545252 643529 250215 482575 62045 533177 141765 516241 589961 32355 756537 117571 821176 354650 339841 169103 505308 817792 589885 895918 124114 282675 771844 929816 63550 685681 799131 311592 521063 469653 34459 28760 983180 688540 937169 753885 70409 501069 575102 92257 513167 809406 456855 371700 524854 531494 658099 875774 802299 879950 417769 460197 459021 80167 132715 111585 910492 335561 15269 734569 773352 601777 929380 797034 758133 864748 169818 880730 182756 8037…
Output: 131952685

Example 2:

Input: 1285 508 791953 609876 594737 156882 291339 49221 242622 818994 481843 460818 181207 546349 230595 496193 156539 67591 565473 659195 245931 290770 836269 560991 362804 118265 711302 920916 524716 996824 979596 724770 924943 737445 836334 864642 235655 862117 619289 230304 965526 178225 880871 205851 495641 154178 657026 805875 400632 748028 381551 263882 92784 503220 892788 861979 83115 567891 192141 821931 97040 729923 607 540858 703396 588897 703453 302761 732474 422155 920352 483891 959992 191862 776390 581653 955771 92112 843969 602484 730105 903091 916507 752893 100403 234711 10417 492830 957345 382652 447105 292524 203841 7707 676757 14972 852136 850620 838129 711386 777320 464581 293630 564907 570775 772301 385790 193011 419475 940090 812792 245756 683640 798633 110603 395142 380645…
Output: 272000328

Example 3:

Input: 1041 798 330114 161371 37986 122568 898258 378911 807120 643718 855109 913791 289119 490346 544674 903942 899463 241726 284955 306357 769 182227 215420 580809 714110 954049 878840 831411 886257 767960 921596 98895 207316 126796 933118 245382 905246 422168 298873 441153 685686 939971 642674 351671 153983 321916 510037 796874 175468 26118 696009 521987 988035 16250 59197 908993 96969 217760 706686 513537 328433 407021 219839 248284 215144 69786 668899 811359 715696 171102 356846 993914 334554 63326 585799 785593 734885 60307 177891 918499 830180 986574 715959 134165 301923 952923 727579 53586 810574 847474 157101 739172 550459 929352 250416 154068 983978 280304 417912 260753 956121 843242 86563 871713 155997 459906 330791 607201 160399 174026 449319 979545 302366 580305 152465 739763 803925 …
Output: 401136341

Constraints:

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

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