CT32671

Sage's Faded Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Sage the store warden watches over the honey farms of Buzzwell's stores of segments. A careful computation stands between order and chaos. 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 <= 3802; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 2253 1236 -365089 -719465 -267386 13855 725583 -659045 -801281 -757042 691842 458898 -439900 716288 -869017 -39847 -610409 -725857 460745 -141508 -825294 329645 908629 189785 33324 -69326 492036 -235261 -880643 -444854 -360258 -856569 699476 101545 -140498 561125 -789869 892553 420762 815504 78492 -960247 884121 527585 180461 913889 -11584 851753 -544090 213545 -749737 -567121 318842 -341232 265765 -284594 -518507 240665 -142055 -703540 -353750 -15646 951296 -281604 -326858 -449659 766643 316799 895470 615590 997422 -512275 973505 -893726 159921 892833 -919519 -974407 81897 -301781 754272 647830 -84853 -857190 -581988 491102 671277 430171 119490 -76430 503071 803590 479593 -912431 -858512 -978611 473232 729275 792256 439292 153267 765985 -132153 -127702 757819 -580719 730925 329168 -697741…
Output: 25314521

Example 2:

Input: 1314 785 392511 -365887 198794 -993749 343150 235983 99932 899413 763594 -528571 -696489 -682215 -32038 -851368 981070 250602 123880 -470161 -182809 95547 -798972 -157408 644034 688944 747307 239323 -322653 -246068 -430775 -945906 609472 -614396 -493847 265089 778165 821631 120933 -79815 -63833 626408 839073 765672 308272 561178 601038 -124399 -264160 -749615 -203662 885325 -366880 853162 332286 706092 -607608 -448172 598386 -387096 -21826 -40841 -845689 -911675 331902 -47672 198115 24299 -259730 44180 -996312 975637 -436716 565714 -372560 -764157 710156 425434 594934 869801 -423037 742880 -37783 406095 318741 311000 -66043 -317019 -299571 338038 560036 805259 282921 -635578 -643395 564744 -689817 -14587 287827 293964 461217 784654 -532278 910167 -191501 -881289 -705812 440771 -891674 4443…
Output: 34498394

Example 3:

Input: 2114 477 -537468 941299 -55137 134900 279483 -208050 -822523 379008 79094 611626 117175 -184906 -643299 200735 -789013 35881 858982 -506812 576130 -729504 -545213 -436613 -280846 452074 -823867 -548745 -847022 577067 961456 272812 -806336 -380595 -143802 213948 19496 353721 -679239 136793 -710008 -890653 829756 -105752 -714927 523511 539209 -304726 956361 -60132 -516896 -479483 300788 -751210 -98047 -209325 -175968 -589097 -515415 823786 -682074 560893 172545 908682 -329388 808721 73194 151184 -127191 558597 155824 -808407 467757 -141807 785713 -743268 -533148 782785 141804 -408165 682920 -930682 -100676 639261 246641 -214772 -389795 323625 -484694 962066 -468728 -231884 277718 -677477 -730977 530747 -32826 -376185 597410 232247 -247112 -778511 405376 -969878 -724775 -212210 423103 -997691…
Output: 21147727

Constraints:

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

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