CT33376

The Fixed Window Peak of Misthollow

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the valley of Misthollow pays by the answer, and Rhea intends to earn it. First: the full register of stretches. 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 <= 1343; -1000000 <= a[i] <= 1000.

Example 1:

Input: 507 235 -778185 -846078 -953857 -244376 -916464 -630433 -97625 -158298 -974944 -788574 -656354 -965356 -612079 -404354 -664450 -183903 -526148 -104071 -438860 -138130 -348651 -544614 -413368 -562427 -318734 -301857 -554167 -562380 -193430 -7424 -599927 -817976 -628100 -933005 -907463 -898151 -166553 -950247 -970316 -702129 -534813 -231908 -905507 -542723 -649684 -343247 -305576 -176422 -112419 -263917 -631843 -55555 -343455 -982696 -262881 -883347 -569856 -709417 -627321 -233831 -416761 -793637 -285532 -788676 -524704 -870738 -549918 -57232 -797807 -201585 -833927 -168711 -717225 -742300 -406302 -600426 -33331 -388616 -314405 -758433 -423901 -148022 -291251 -707428 -72119 -671278 -865830 -359916 -378520 -422849 -167028 -903192 -89076 -302150 -487034 -787699 -802469 -115977 -186850 -599196 …
Output: -113946261

Example 2:

Input: 689 192 -363264 -665886 -839441 -617672 -215626 -938616 -717886 -490788 -231022 -214984 -850738 -467430 -788188 -553955 -945599 -234758 -607098 -40916 -435963 -658276 -912131 -564381 -933333 -238244 -8448 -278792 -768261 -259109 -492678 -33814 -955978 -512947 -657654 -393714 -938230 -179499 -848699 -622719 -622038 -266675 -687480 -446488 -81264 -146519 -50285 -578538 -302864 -825469 -985052 -83110 -432920 -189518 -173128 -495820 -152512 -203442 -94259 -620929 -86927 -943811 -754157 -540236 -189539 -607898 -554167 -337025 -285429 -361442 -286278 -535729 -485204 -885190 -666426 -227325 -971627 -954053 -968398 -309159 -206967 -209442 -530525 -617384 -666677 -848079 -381795 -28092 -796199 -721012 -983838 -346861 -781825 -62604 -192170 -745228 -757387 -925669 -141517 -538022 -922694 -99227 -681…
Output: -91357349

Example 3:

Input: 70 9 -139400 -582080 -261556 -640780 -641633 -309349 -840811 -270705 -847440 -369810 -773190 -933192 -320055 -565070 -603117 -53132 -16829 -645052 -357691 -738251 -153430 -521206 -903308 -389291 -550500 -201380 -909589 -821369 -569008 -911588 -914944 -365238 -960537 -158793 -334875 -969369 -867594 -689159 -936259 -867741 -123558 -848536 -259106 -639222 -411095 -394059 -315049 -794032 -752271 -276505 -640104 -640337 -250836 -342997 -723022 -308508 -113114 -178855 -486295 -21521 -969338 -185901 -385739 -930303 -500636 -423374 -515707 -121705 -355692 -83128
Output: -3065485

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Fixed Window Peak of Misthollow - MEDIUM Coding Problem | CodeTikki