CT45383

The Golden Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the ember mines of Cindercrag close for winter, Sarla must finish the ribbons ledger - one figure at a time. 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 <= 2077; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1442 387 -953987 -757034 -752962 -452867 -672530 -126006 -784783 -479082 -209954 -403737 -18839 -550300 -886544 -465994 -505160 -193219 -305394 -286609 -224451 -413468 -181345 -882725 -436526 -248256 -463017 -652280 -927473 -775209 -743322 -492503 -104072 -896546 -100415 -413909 -126058 -821858 -855881 -986162 -610339 -866786 -320326 -607886 -721921 -819438 -985634 -260989 -557967 -351871 -804070 -954245 -368086 -242050 -971234 -697170 -381391 -905361 -531027 -751964 -414556 -50302 -750330 -174260 -251329 -126872 -698001 -275128 -308720 -449482 -74821 -267095 -19916 -743283 -189323 -79035 -852941 -985046 -101456 -917768 -173275 -402761 -435308 -397659 -746264 -421520 -556458 -930125 -419102 -87990 -881623 -783577 -915755 -467670 -251157 -153882 -926426 -331930 -661033 -113757 -625714 -8079…
Output: -187516373

Example 2:

Input: 1341 221 -791136 -722525 -460023 -61027 -312086 -261456 -564355 -8586 -348155 -669024 -407969 -283928 -249846 -480078 -558425 -887576 -703501 -635555 -201700 -12309 -993316 -989875 -75618 -821551 -127891 -102086 -920868 -39781 -408839 -310161 -428087 -174204 -933568 -732616 -899993 -533345 -321277 -80533 -940213 -763726 -334118 -991094 -729889 -279328 -741208 -247352 -619082 -616674 -2645 -75518 -435141 -968718 -282726 -92181 -180520 -577223 -497620 -758425 -909810 -346156 -600174 -804189 -309204 -836321 -956820 -63709 -133610 -725937 -977642 -95345 -605079 -141311 -967289 -850829 -372509 -294103 -185014 -624241 -16219 -201391 -970929 -638560 -110931 -750064 -76671 -347901 -830279 -339325 -316191 -28356 -239562 -72456 -527703 -862752 -567572 -386400 -726184 -43288 -195687 -607288 -25624 -7…
Output: -104227456

Example 3:

Input: 1214 1064 -533871 -335523 -466413 -481223 -308944 -765081 -342033 -478087 -602609 -769607 -26954 -476321 -527697 -720192 -825882 -372653 -908925 -830436 -989439 -674871 -527168 -703826 -619920 -547301 -591868 -528127 -351801 -631784 -842488 -848626 -873801 -119000 -166957 -346117 -959786 -510455 -673438 -634607 -441470 -653973 -36743 -71772 -782896 -334688 -937417 -25316 -505781 -739013 -150000 -737868 -955286 -188627 -631858 -893307 -281311 -543890 -563838 -898025 -983169 -358639 -631311 -634444 -825166 -603228 -405461 -789271 -488414 -441215 -982474 -320477 -536469 -342092 -506991 -63357 -648905 -601584 -192724 -705946 -108747 -116307 -395239 -778588 -767833 -114904 -217975 -975359 -261842 -404077 -915563 -702329 -800771 -172835 -157421 -660415 -564794 -387286 -27615 -757730 -152403 -618…
Output: -521166933

Constraints:

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

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