CT30905

Smith's Fixed Window Peak Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the ember mines of Cindercrag as Smith unrolls the day's manifest of ribbons. The tally will decide the next shipment. 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 <= 2666; 0 <= a[i] <= 1000000.

Example 1:

Input: 1235 930 810 93798 205802 944920 985258 112791 950677 114546 277626 165449 133971 978373 939802 771567 108273 353013 119708 555559 71391 444811 147131 598341 669868 939608 142103 270870 326347 669045 199558 578305 86434 111235 896308 57910 658731 397070 800423 700315 641722 111619 861339 858212 755424 448631 114490 128750 76341 969194 987537 917993 258815 963937 171881 358214 136559 249418 260543 864700 909549 708178 334098 160751 137641 64163 900324 816938 318505 280065 932144 474618 997775 823122 543624 516198 995289 266185 761392 129828 179764 810349 73987 574742 557668 794068 107944 290950 616937 980855 540675 199200 979658 995608 259419 409108 70087 237963 243438 685379 785560 395468 442197 638153 501704 171137 480087 334117 386434 482837 227348 229544 33419 595750 138085 2231 20587 5…
Output: 464831763

Example 2:

Input: 915 501 996722 231564 43762 575588 240384 785590 611272 210915 29776 894060 883652 277673 789419 637153 570603 113596 20823 124552 170988 648442 354660 872886 239219 571515 386169 483500 20594 580162 162058 408196 798555 858154 534438 897930 571293 921532 822209 307151 833614 174045 168379 578483 931253 97650 607176 801850 324227 671666 138763 992815 981466 477207 771594 441179 416808 431272 96803 969717 640476 651779 797744 607524 465681 938681 8453 14707 294287 58157 644826 438356 233364 352430 490048 192477 741118 523830 608104 357865 578844 499807 217077 54440 353249 136405 859428 318748 557805 86842 205504 628750 859178 2600 556388 503323 973192 87378 114927 193202 943444 412868 270708 158638 310974 300422 943064 115912 243169 254918 712454 956283 486268 569250 617731 140717 818938 91…
Output: 255124785

Example 3:

Input: 1443 606 391823 574787 311268 75144 330063 492584 315772 440913 937709 544428 259207 683490 405603 113638 429453 527318 648712 552116 524219 932167 547314 824632 405611 379808 204749 207036 844059 310808 268612 456469 526550 859239 614110 580021 657028 470793 442506 101080 152099 460702 41534 553348 315044 127796 393657 936608 598082 730410 181093 809425 841908 324622 662990 604303 12488 867547 464998 8922 671232 281155 75991 798152 14047 853169 214277 53307 70166 131369 678238 142556 958606 976062 36643 387390 76224 464362 755691 31107 888336 905564 363916 370822 755045 883409 87369 336724 216172 259024 11736 327509 303504 933777 106857 967701 116161 986305 31237 71407 164060 627846 46390 436756 167221 48951 285159 108095 347991 675263 922402 990415 13227 925690 389043 55510 253771 651792…
Output: 308355237

Constraints:

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

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