CT30186

Cyrus's segments Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the shale slopes of Greystone; Cyrus weighs the day's segments manifests and starts the calculations. 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 <= 1158; 1 <= a[i] <= 1000000000.

Example 1:

Input: 251 175 950454672 773948157 851542431 527517569 656346636 294285817 588602040 726718685 751176257 933795255 799635057 601670169 597713258 702016632 486729766 505214292 743387033 541916660 613687527 41656765 351196951 247203545 797899988 100595134 133971850 689138727 86487644 385985113 941553763 428259452 797543163 193838354 774075288 156800978 748257739 421797682 14185131 627401021 942709314 153228007 517392057 271090888 763210749 984465808 963904729 446433090 811017624 702951032 430629302 27847668 883632991 234866042 658038733 938471920 556573082 423065147 785602136 50694381 331356821 550794257 825754942 781685483 477954953 310402270 71312652 732517254 38975717 363287814 306376090 207199185 311980063 44124743 634840098 740445978 227950440 568668935 278183327 9744028 356131163 768498884 54…
Output: 92105927825

Example 2:

Input: 4 2 133756052 76332253 534504960 359759528
Output: 894264488

Example 3:

Input: 687 282 11672318 481841290 154511458 173737716 816943010 587365063 456099829 386058131 188347034 512683259 34530316 7134643 472009311 916462937 907750222 448405222 497392549 193880593 859108348 633983934 181517532 722671389 597841411 340277989 383681 849011875 409286016 313472991 637151243 282232017 924844985 692696983 60706179 780525345 633277615 489883535 748273490 380307530 526935001 391315676 201621773 363707073 141587261 902493991 714085757 68709509 528402038 28804308 915113409 37103548 426323439 524620989 185682589 70189259 636817270 252057190 514299563 970935600 549562315 800517501 993276944 284594229 591237293 790147982 408915641 684930056 411107532 457895239 657322087 196908322 960033528 883214290 436486684 386370277 738471558 601717565 637446914 886448455 813944794 47212714 55273…
Output: 149341677891

Constraints:

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

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