CT30058

Gino's Twilight ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Gino inherited the fish market at the salmon ladder of Rushing Falls along with its curious bookkeeping system for ribbons. 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 <= 3458; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 85 20 -39142 368273 -807675 505248 299369 726565 -144339 -515992 379484 240724 -216413 -831279 732155 823387 -730289 -593937 319069 917792 -636376 4098 226097 408205 -351401 336613 -373198 -474779 -926587 -939394 444424 130239 -607142 -459277 520859 -559342 279435 760950 199178 70886 500392 -656135 -550787 -697764 -397336 800084 825072 -211884 -897900 164607 -895601 391101 -58339 -495377 -973715 -720462 -948932 361460 -553736 798939 -94644 -538804 -174437 -850197 -739816 -787936 118887 -986300 735359 -618085 426155 42312 205517 -402207 395903 498140 196186 -11805 -776168 444899 583727 650690 -295243 342069 39690 680858 -334069
Output: 2270584

Example 2:

Input: 1977 425 101776 68764 -417413 -960848 -753311 199253 -624146 -21031 -356288 -822469 251553 982930 935934 160600 -282562 -742819 700874 763892 126032 946149 -884863 -630951 414015 256155 333249 -600995 503463 -974562 818833 -473288 353574 178024 443922 57486 19288 695409 -556229 63798 -738542 -161239 621601 55451 774772 -266043 -12644 -144445 904255 931873 -424786 -125679 -111710 497674 702543 -544916 789779 431430 -532771 762780 223422 -490088 -188661 595047 -829372 -154506 499580 920339 261658 310040 -264550 -240769 -923649 608871 672084 -124116 -234522 -543118 844045 369109 -857054 597661 647266 224258 95750 43496 473980 -24482 -246468 -374996 586787 -324070 -59620 293296 -151529 -297989 -584326 -332520 -468634 369924 361355 167370 -157450 68533 -581343 86423 374988 -521392 -429227 -6173…
Output: 15961363

Example 3:

Input: 2748 977 633276 167543 -310190 619239 535640 -144535 -271359 -348229 -671081 -570768 -494817 768219 115173 401902 -779435 -68470 127121 944177 508129 -306026 -461034 123023 418851 15486 -110136 721928 -491559 32962 556341 -254534 -144752 -737195 158171 875454 180914 -808220 -365509 275845 31743 -462865 -556838 -651153 426381 961206 642452 198389 311199 518444 421864 -436721 741972 569357 -85308 -780836 326692 -99828 800369 -606808 -251997 -835638 -244138 -992964 1692 -201169 -732855 -962290 -473788 -500240 -383113 -94344 391316 158520 -373013 -726214 -279188 -107628 -338743 656459 400313 913014 -840388 476903 370824 667312 465748 -989620 161595 939100 -577878 54446 -436999 490176 973240 -794153 -240287 498756 -951761 -682378 -441217 -81188 178433 503861 -624748 -223243 -117276 688349 53755…
Output: 54402201

Constraints:

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

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