CT50995

Cressida's Ruby stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The dispatch writer Cressida has been asked to approve the repair estimates. On the desk lies a long table of stretches readings. 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 <= 3340; 0 <= a[i] <= 1000000.

Example 1:

Input: 2142 1820 491163 652336 331514 43711 42636 913482 511664 435250 618101 249893 332342 117356 467950 370757 246626 584258 916393 631338 171879 850776 566324 27462 445720 192478 994802 778122 627777 878316 919104 791022 360619 971553 122301 398745 684400 640373 340957 123177 317019 271074 537563 752639 923408 157229 198032 410154 442867 681277 19803 24562 26092 416214 632952 866718 258736 518469 918734 599417 313497 487255 232048 407998 468525 303937 324147 349886 358278 575040 311856 91757 736738 199617 811407 403347 343871 94863 4132 103945 417990 762658 361999 641056 507482 569378 203311 315081 438038 697878 765826 126717 220964 57199 647569 471972 692827 876465 828038 555767 134949 16182 256277 435282 727975 464024 909398 945310 418479 118622 646714 309757 212525 423792 598502 373602 9657…
Output: 920821522

Example 2:

Input: 2674 432 693019 922771 399174 897260 883709 826313 767979 217834 519498 604507 523071 137854 706825 125829 717861 113991 440909 998488 855312 214074 206142 857145 183105 854698 464190 120070 95502 384301 524636 508706 13096 450597 476911 476871 758388 574489 442952 94788 297686 38007 377390 265082 600743 753962 840321 318877 412878 512332 437264 563328 485218 691562 297403 230794 976059 634474 437559 256071 386057 472749 44191 178804 69754 308093 473113 243946 41273 871257 576872 324901 134097 576899 825768 801255 869927 874987 24789 920191 25023 958128 144154 308904 611829 405211 129822 913987 616892 796177 533510 699043 737060 111375 542776 160233 325040 518327 775309 872153 557519 555448 313377 899399 56939 355542 108501 907694 664169 935049 953002 67676 907964 511112 281644 402935 7365…
Output: 230062224

Example 3:

Input: 1695 1058 713540 898821 708657 811176 249583 287799 771429 562353 883384 816039 859453 549638 627472 423039 919718 845092 727162 441603 680094 401672 838830 977722 948332 48581 277364 992036 773621 705190 862842 249128 165646 218601 460242 664280 688615 180331 887469 573196 91184 540167 289706 389156 304986 656119 145646 38454 328237 476822 223536 78925 926880 232510 651620 461962 877250 804316 733398 467181 650233 417858 880569 742781 752565 956785 490494 372049 38446 974697 63500 494288 41226 359871 931097 661045 125658 726773 569505 498145 69729 242367 892247 571237 632270 156581 740427 393858 397110 646354 768503 119789 527876 960337 706078 134062 808904 349187 607754 29236 129283 884844 323309 123868 294244 653844 512736 732427 476594 418104 575569 750107 866968 1907 806590 904698 256…
Output: 539135805

Constraints:

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

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