CT39015

Silas's Whispering stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the tundra station of Whitesnow opens only for a perfect tally of stretches. Silas 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 <= 2560; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 740 568 684133581 542045927 860574557 613594998 952881989 884827619 653751286 546841399 243505368 551671779 122682756 343769836 841118108 143712789 676072085 420630200 607638830 990755035 942172180 92324844 516905080 766991377 297954383 630250131 421238821 388951496 832966186 370635965 126635442 295516086 272007353 55316493 582210961 861763835 671529755 216744337 522884128 375535594 494662026 67226029 339096026 655908813 621203228 386269819 576386919 403668344 980524505 502637233 390343262 999348624 382437973 403130950 134164759 863773238 631619397 303510017 753689674 934574961 975873812 700216739 172009636 805277952 636052203 279123501 411111035 398202697 886894008 18101068 57164207 698414355 599837567 988194461 231208613 323934069 813020989 121584809 482536346 593827621 354973461 3783214…
Output: 288458579163

Example 2:

Input: 1077 475 14802588 881504796 671693244 656971173 277195772 524758521 661085725 79470603 188081599 878515206 394092906 837999953 728282314 196424754 26502475 34096707 302204124 893774618 17866056 925894597 907905653 415662313 123922791 582955596 396158434 57354980 211767934 364817661 611408472 893136555 318761081 550461532 27453930 140920184 328983215 277887807 220200984 462995023 256155251 411098012 490250652 797195597 201287595 263573987 420557321 123631498 828416895 123201664 888247639 59962085 226489677 148383871 839370976 206999205 716943014 576380726 144443521 50526748 723872446 673690207 709631165 278952361 666273084 995848584 516521015 972349757 242570099 972538942 342289869 233408032 884562805 974860263 352434444 309103467 402943513 341860627 172488294 906139958 152712701 696816829 …
Output: 235750925969

Example 3:

Input: 1382 226 712487594 195307177 942461571 192408202 974806609 420425454 524798945 33253229 813575692 57396623 919622223 835296368 627205165 623240597 287470081 979789934 190635675 53881901 276650541 667527372 847560304 946373043 506546005 28486999 808238214 29234405 832949822 934033103 899088606 833083845 997012837 498806734 356637505 697711522 861360124 121419707 593188967 157041230 591285611 749820958 453283449 77178934 844837518 745188341 502765465 917369225 763245591 210563867 393826458 370789577 964149115 776080698 64661345 376644343 568942987 41619747 130795395 742801325 377889286 787094820 148259094 100693479 62037151 23433872 455911899 736054568 959070513 206623037 314881387 929053842 971450822 323826445 129749330 685560725 457847012 102371790 54748465 630522803 624421908 66574760 248…
Output: 119085403871

Constraints:

1 <= k <= n <= 2560; -1000000 <= a[i] <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Silas's Whispering stretches - MEDIUM Coding Problem | CodeTikki