CT32346

The Silent Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

It is audit day at the wheat plains of Amberfield. Jace spreads the windows records across the table and picks up a sharp pencil. 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 <= 2736; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1937 627 -518252 -361005 -900795 -889280 -53915 -331067 -739743 -884908 -647321 -59858 -942585 -34318 -586649 -619159 -948507 -701959 -742501 -807173 -4214 -560848 -686255 -354798 -203243 -9660 -429167 -435477 -777011 -689912 -203018 -940359 -700834 -443416 -285008 -336733 -22458 -251282 -201467 -949920 -753362 -532700 -731703 -132468 -228586 -35796 -46511 -165890 -100708 -204706 -696216 -824279 -677380 -287737 -136606 -480999 -753194 -20451 -446289 -176521 -592959 -552695 -799565 -49085 -2323 -685351 -429169 -673540 -902141 -231503 -881792 -945019 -506046 -817635 -301629 -349522 -742897 -605115 -735526 -48093 -556631 -726850 -231378 -714063 -67866 -801348 -719421 -605818 -181329 -16710 -963769 -302740 -423706 -790658 -73114 -858066 -459725 -897157 -987645 -53047 -891157 -558905 -155113 -6…
Output: -299219823

Example 2:

Input: 1819 1773 -586977 -154403 -336212 -254437 -153951 -19049 -839506 -911347 -406519 -861213 -375553 -868048 -760400 -403668 -682336 -353143 -167715 -825422 -76059 -723631 -531342 -439952 -817659 -162818 -808614 -987972 -533364 -296860 -144598 -631761 -464840 -29179 -324971 -7462 -741653 -337816 -937146 -328292 -290042 -325455 -154601 -669672 -905569 -376014 -382514 -356118 -560786 -90321 -368811 -349778 -326382 -130478 -480699 -515983 -109585 -748967 -283997 -588937 -255653 -65100 -192013 -237919 -681426 -35654 -768604 -260721 -748713 -550329 -969680 -630127 -758932 -215102 -337622 -343633 -857895 -52925 -436822 -448282 -44555 -512361 -245312 -295147 -780650 -832982 -98301 -871088 -588208 -980654 -645454 -769423 -487396 -967381 -105830 -812558 -643937 -30784 -413468 -526590 -661013 -628345 -2…
Output: -866017851

Example 3:

Input: 2246 1860 -306974 -909848 -179894 -490976 -544354 -425404 -932341 -427198 -404825 -767896 -259466 -29108 -616022 -616612 -826570 -23395 -100230 -936876 -256307 -722017 -439813 -145523 -736268 -262189 -200049 -483933 -518873 -676763 -103067 -756979 669 -551145 -675996 -847473 -254202 -615562 -833363 -446015 -180280 -294075 -741498 -234102 -281175 -344578 -600751 -923909 -309323 -321606 -794079 -702608 -566948 -776921 -327579 -338524 -852036 -516605 -57354 -152769 -865220 -117862 -654389 -18366 -919143 -322674 -424180 -978321 -591430 -999345 -101821 -945666 -138001 -427594 -596443 -870785 -805424 -538961 -528921 -582613 -885560 -913494 -443924 -394446 -393052 -835175 -908602 -65137 -689586 -866760 -207978 -919394 -30908 -270893 -189667 -288702 -86842 -409999 -216724 -302034 -187239 -898281 -…
Output: -938685871

Constraints:

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

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