CT56310

The Fixed Window Peak of Alabast

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the ivory gates of Alabast as Shepherd unrolls the day's manifest of panels. 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 <= 2999; 0 <= a[i] <= 1000000.

Example 1:

Input: 196 58 115957 494836 14834 261619 426502 58509 496898 245967 232721 175913 665258 122278 150324 372617 328248 105511 174462 543528 896044 315111 393277 675248 609175 884384 869975 728856 370605 144687 557098 120467 525284 807890 820397 456753 561846 52846 96731 396691 117388 521557 826350 956729 214992 417352 18167 366413 341113 277569 525960 906742 34551 320067 139006 243480 624963 410642 812173 219296 436829 458793 780882 360531 234599 426858 353293 314308 380927 938590 192681 203374 964249 250016 963598 670878 754432 909184 68602 449547 250676 464229 360334 183180 393086 464656 214568 868071 698892 498028 663736 644663 240037 497411 782911 763988 821309 790647 416283 655148 226553 207885 434036 76483 890401 54092 353750 385970 927117 82213 705041 513180 587751 524108 223113 176941 75923…
Output: 34884378

Example 2:

Input: 1124 895 896156 594658 693139 931987 329602 166240 949814 720086 485905 350554 736626 272240 170261 786970 749353 967224 633270 464170 524774 843262 605634 137791 219626 753120 235058 6020 14594 482876 559298 131905 519997 559118 737951 995716 85362 131738 487145 295959 795356 115106 704169 238966 74472 39397 451627 596791 877695 319456 326546 482809 47270 480038 809695 823948 736649 741330 556510 585197 988141 288322 35805 832921 471585 670023 154496 276276 655301 893330 301262 876170 756436 183702 913512 100629 452168 725592 111967 16174 873088 539702 589887 834539 915873 248793 763293 259951 40382 93972 163448 620753 317290 223487 293519 622208 262500 72982 358010 621082 52216 952893 920421 626073 375925 584055 865097 611890 68356 902310 61945 288766 975766 41837 871017 490093 893877 75…
Output: 451035482

Example 3:

Input: 1209 718 417980 675878 790404 505058 292585 179277 237193 968683 948860 393542 875529 806583 14251 155148 24510 796921 405370 276856 190278 969716 798253 564175 16992 81957 475392 175214 288454 236511 354957 398722 71434 127723 600080 575757 716355 558910 643364 641566 639063 508702 388054 205421 431873 860943 929396 989411 495647 834746 833580 340011 945740 17503 70678 688546 166716 900550 78324 715728 635196 198044 956253 665847 177136 601697 720793 323806 316356 877773 936095 904099 801941 754007 30473 914601 52462 635049 782160 793903 960192 78471 11175 551013 435583 300830 455748 879862 228222 617474 270619 177537 142571 536391 450126 13784 177590 281588 493046 164736 963581 569043 82514 463675 602474 353815 354465 869621 859114 717075 121538 720240 938240 826507 509128 576536 326923 …
Output: 358025113

Constraints:

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

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