CT33773

The Fixed Window Peak at Tangledeep

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the kelp forests of Tangledeep, Tara records each scrolls in a worn leather ledger. The guild wants answers, not guesses. 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 <= 2392; -1000000 <= a[i] <= 1000.

Example 1:

Input: 618 355 -503963 -834578 -511525 -841231 -314123 -110744 -153208 -795533 -557042 -440120 -295640 -253871 -983123 -308544 -613935 -785842 -707686 -997418 -277938 -591097 -104646 -5914 -539100 -60839 -915116 -249961 -797423 -567357 -844526 -117898 -11476 -874443 -814577 -658138 -41910 -736631 -928131 -414585 -148233 -487932 -574506 -190214 -955736 -681857 -122629 -514487 -478018 -716794 -747869 -540785 -335107 -800143 -275482 -566078 -957691 -8688 -725142 -698835 -254445 -540398 -393616 -209729 -160173 -967597 -864056 -405500 -33114 -656487 -74513 -983341 -245481 -493793 -294802 -229887 -189109 -25195 -864178 -184840 -702104 -180377 -882343 -271699 -667769 -826793 -117941 -143334 -869237 -925231 -313796 -988808 -829957 -450052 -845390 -480271 -228504 -336085 -684471 -985718 -884012 -608515 -8…
Output: -180099886

Example 2:

Input: 1431 1100 -884002 -493221 -922025 -549771 -402669 -206193 -80883 -110190 -658476 -100138 -165794 -665409 -531489 -239574 -896686 -773572 -387032 -901606 -435022 -892765 -491450 -727644 -989381 -501604 -926152 -201410 -142767 -264725 -96260 -797657 -984649 -756772 -577708 -478158 -642393 -656683 -533140 -890443 -457742 -829615 -124736 -669812 -302613 -105326 -328461 -437183 -306914 -283521 -91470 -431162 -611524 -362144 -517412 -315864 -363553 -876197 -94868 -832928 -432438 -172035 -411622 -691088 -18938 -363473 -496356 -294400 -953314 -267629 -576577 -545067 -582154 -100655 -791985 -409816 -95264 -137590 -162417 -684918 -949668 -466537 -634411 -866592 -467799 -541903 -882084 -931044 -491786 -350736 -392656 -825476 -711088 -806092 -386625 -762196 -10735 -116791 -162083 -432264 -908558 -1846…
Output: -551108892

Example 3:

Input: 2140 652 -959397 -519403 -804026 -739432 -72119 -523884 -970723 -431258 -736097 -493355 -285387 -595455 -373434 -539553 -720576 -216274 -549488 -462836 -333560 -864260 -474108 -791992 -925132 -763814 -601619 -781774 -404883 -820992 -713868 -621060 -380464 -918547 -270669 -626102 -639081 -601834 -25655 -618397 -201737 -160053 -368675 -879121 -140789 -920882 -683329 -823770 -2814 -511269 -278618 -849834 -16874 -966070 -401504 -83480 -392096 -589136 -414771 -317929 -490329 -70759 -713021 -711904 -26733 -252496 -330684 -271306 -21495 -919326 -416844 -813438 -507159 -912848 -904465 -144922 -598330 -707639 -894548 -750488 -891425 -418512 -747980 -179822 -820841 -549877 -383084 -102101 -353391 -490718 -1766 -661667 -276351 -672917 -865373 -733549 -410897 -894211 -907958 -938319 -450996 -97147 -17…
Output: -318177248

Constraints:

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

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