CT34853

The Fixed Window Peak Beneath Will-o-Wisp

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Ysolde inherited the gallery at the fen lights of Will-o-Wisp along with its curious bookkeeping system for segments. Time to make sense of it. 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 <= 2254; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 136 90 -839297 -247339 -697037 -354058 49386 -716306 -583650 503762 460969 -707350 503457 -668848 233675 138317 704213 -723539 799628 766830 438086 -371309 385995 -667663 -782155 111748 333710 628616 841257 407855 194797 -613493 -865632 -504057 -365725 -990170 -731547 -458754 971081 -987779 444161 5420 929133 -401359 -712844 -252595 465486 518368 -421240 -736812 127959 -102511 116660 621692 -583583 284249 -526629 46546 -520520 -53976 824067 -848731 -615385 487228 760848 160006 320601 -145914 40376 -634434 251178 777853 68946 -803850 -69306 -600948 149637 801599 663024 866099 -701143 356632 -34144 -394162 -73020 298055 -37718 -885757 148140 584048 -257635 -219209 -713186 -129311 -447447 145676 113972 -417065 -722309 -251663 199330 187449 15583 -63362 439854 -992021 326346 -289680 470884 -64…
Output: 56795

Example 2:

Input: 113 77 -948658 -333991 373545 800246 -423606 -365607 82438 -826871 -990777 296708 660802 -396220 595803 696033 -526609 -337912 437961 168809 -661082 883765 -966022 72120 79225 -831808 -175899 -509097 -233386 771171 -668371 76899 -686222 998010 543444 500424 726104 2434 -899116 -534821 587435 67282 39485 -291552 -867315 -870892 63658 -354389 100739 45524 -171168 -799016 -100623 -965479 381149 -537983 -581601 512587 -629911 -952383 -208659 -703977 -96770 612948 -758898 224328 -410901 -638627 -160984 106984 342676 8218 469784 -768413 192344 -315834 -890759 274797 -594459 -270731 609610 576726 587962 -284612 -886277 -667783 -156113 -662688 798482 820406 30385 965995 -528451 836180 215414 815703 924116 -814620 450581 439206 -24167 131251 -658249 680020 -961062 184850 -261598 539994 -729539 -424…
Output: -4482969

Example 3:

Input: 444 364 389730 640911 -785226 -214740 -962083 -611050 86376 8464 -966099 -230922 -777848 991157 306460 -931037 338546 -245552 944537 -101184 -478484 -591564 -507864 259301 -352447 350882 381714 -267921 311829 869522 -536123 -427637 -534017 710861 372031 115332 -174525 -157370 986398 -237605 -132243 564403 -553090 92756 -92710 -509268 -924417 682182 777301 -443497 460585 897808 -322430 509357 -909165 135626 -533153 862825 994300 92329 401492 -110853 -900828 -974625 766510 -18569 -639418 392083 -423316 -266884 225256 -509649 -279606 -977018 908786 749600 682631 828309 -855534 -71439 586979 -638595 -861853 36148 899565 38481 422316 92391 867475 -513858 892810 623767 882176 358938 633375 338450 -793604 -529411 53905 -766385 -471753 196558 541454 102238 -675700 -943287 -335540 551612 -160817 39…
Output: 13995799

Constraints:

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

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