CT41226

Cressida's Bright Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the basalt cliffs of Obsidian Shore close for winter, Cressida must finish the stretches ledger - one figure at a time. 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 <= 2454; 0 <= a[i] <= 1000000.

Example 1:

Input: 1964 536 90928 16508 329753 113568 627917 860436 157984 701064 557535 718895 192759 328608 71628 919881 388180 60486 874799 115902 871418 224586 928000 123612 299342 925059 133710 362185 611139 873366 762145 368671 533933 708245 552206 459491 489397 819124 931227 993686 319888 529467 754499 21864 495474 706444 455465 58705 425725 204715 763306 31319 57909 175823 671968 420218 454643 58413 830930 84060 672414 324261 262493 787009 22240 41663 591073 526059 967892 508299 55018 254879 240813 810049 980923 19579 524078 905068 782990 479653 258094 557417 332263 669833 572342 898708 904583 350776 376050 92402 593154 667819 366802 996043 216340 739067 914457 51879 93845 724516 774545 789861 187186 412025 688650 703757 773807 113322 618568 581176 294478 500770 553700 684472 937116 927203 876051 737…
Output: 284002263

Example 2:

Input: 1042 863 375482 772309 206181 403914 67084 536952 543986 294876 780046 83338 990950 140355 703173 403217 599457 455859 409456 34837 425755 442886 219334 960841 672705 222170 274707 346389 382174 790629 975268 462674 708954 144809 764750 301875 432784 313097 713956 392155 381976 268023 845594 264788 908351 767332 400242 328406 179321 910484 922841 517091 322847 41534 967964 859367 592132 102833 942271 648062 261097 537 128520 240660 311287 640596 964814 371401 936745 401030 114795 903740 441667 24713 584914 680101 215334 453604 686418 848370 460457 974153 810124 980691 80106 428532 707461 525493 792432 373468 239855 255522 601856 964589 345300 736116 668743 305642 608396 148085 959407 528502 175434 546488 701563 186839 103217 244071 74658 509781 799306 849229 46727 390359 107969 202211 7419…
Output: 455863199

Example 3:

Input: 1721 1717 527218 402388 96484 936675 902124 870284 586837 146487 501721 157394 998590 71780 773478 981495 358911 48744 271951 45910 531830 318921 856509 873132 693782 805405 386016 404081 872895 624768 401733 346913 903803 269469 268910 73310 43623 852947 216280 245794 3028 329765 759679 737112 765868 723193 900896 762073 423047 769893 343319 458244 389304 12303 757023 617787 194989 906018 263662 941732 148812 376213 935113 779322 655282 290436 411721 652228 550967 27062 881831 700077 665921 122847 94355 548462 824445 418832 643559 786881 127612 164319 591208 909031 110442 520692 898809 638376 128940 327024 773559 640379 375571 397332 688331 96030 872827 482096 253886 140141 949882 855660 75800 438642 568091 384525 795074 500611 495218 993336 768245 329553 512775 797240 33676 669461 399542…
Output: 855298862

Constraints:

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

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