CT56477

Quartermaster's Fixed Window Peak Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the foggy moor of Greyfen opens only for a perfect tally of stretches. Quartermaster 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 <= 1885; 0 <= a[i] <= 1000000000.

Example 1:

Input: 961 298 727901813 314699411 701047887 91170694 30503976 85450945 976245457 74671072 922193426 398611127 439699684 434770858 568509413 44515873 852297451 51451877 596362308 161068872 867558183 93924402 165635409 980855692 937693464 351734134 943243476 956171799 301961021 386248987 955590053 779799363 724422216 631821321 85791109 635628923 178978871 205589795 211507066 974983184 788114538 578224764 104824915 299086305 627506836 119169613 764982929 436409622 897352101 812913643 598875303 999523783 809373390 192618349 594596505 165712304 349608428 785297275 843261634 841299479 607297895 766613133 6026107 992713927 71295147 827485910 627114096 203729978 578186140 424180562 303457011 50393001 325412676 28634397 688096747 660771806 142242395 269851422 506718897 257001511 565277881 443768500 16849…
Output: 155737285594

Example 2:

Input: 115 21 676365435 5216313 982525997 862368916 326769710 992177159 441297264 160859576 748813931 662801078 762332428 612132300 376844418 674634882 867193501 677781919 111723002 388421409 308731822 923689421 713246501 99092877 655474851 656798986 769148426 952176884 930794096 898684683 659999428 981074482 917176548 69413986 851884569 474036520 684174583 290629675 767261962 165557529 704296832 594952876 627431717 121048611 71093983 797151870 846197605 870403101 867445936 997284353 979457060 789916410 280873919 507776989 86477088 947440363 588334991 366491864 645225564 333505089 702770499 170448315 898988169 271126194 604762092 434801375 629936308 204672230 34314790 994360436 129804996 709279711 14543580 123624908 665608691 381390975 29958882 130214427 954155158 29113889 512071172 342461586 669…
Output: 13937152864

Example 3:

Input: 1631 241 870316267 88866250 603680395 464317994 456074736 612737794 882263453 698017841 643733973 847900678 482370240 274277798 173161761 98490625 52131645 131314460 527909294 758044319 653036690 853059387 807153192 505145061 366843746 18380166 855005810 79014144 73029151 172689371 603280713 56169724 711155356 381133565 441535085 199487150 737500556 237986380 221843002 235182836 300045664 740411475 417439257 316287269 427177887 497197038 394051101 197040510 216153738 800118787 271303016 106987341 875880894 708510666 667839043 602462098 602605435 756737586 23174606 936053823 607532716 540797542 727514864 876219711 542685542 318116715 508479660 989814475 164387346 295640253 883295938 521416125 916418979 487620973 431699416 158957555 173071479 953313133 833608543 812259814 748252871 931770515…
Output: 134688776170

Constraints:

1 <= k <= n <= 1885; 0 <= a[i] <= 1000000000.

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