CT29815

The windows Fixed Window Peak Puzzle

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the monsoon port of Rainhaven, someone must file the annual report. This year the task falls to Emir, armed only with the windows register. 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 <= 2963; -1000000 <= a[i] <= 1000.

Example 1:

Input: 670 568 -423582 -489896 -503819 -790764 -966433 -274688 -622439 -790029 -384559 -718803 -82 -400148 -489504 -459041 -727920 -176774 -367759 -512151 -745082 -616940 -300930 -485987 -98731 -202542 -232085 -969150 -204210 -659884 -145972 -857671 -491480 -219549 -125649 -241097 882 -288539 -157314 -434932 -220876 -855002 -685728 -115639 -671353 -213893 -105493 -296227 -130753 -861109 -105749 -168206 -492311 -596335 -950866 -925425 -386117 -48219 -831686 -948878 -181987 -998759 -736156 -72306 -110261 -334519 -182455 -365064 -593103 -765336 -686873 -18862 -571277 -626036 -801929 -567488 -143257 -679860 -97018 -183584 -168917 -42001 -990656 -884803 -889690 -777245 -369323 -456376 -953665 -885772 -554586 -394612 -676922 -169671 -175795 -320334 -223911 -314476 -946166 -50527 -138153 -828880 -682626…
Output: -272021769

Example 2:

Input: 2633 1714 -236816 -140718 -676406 -334725 -72061 -212427 -812916 -678897 -770600 -43837 -180696 -743273 -119098 -516086 -168824 -296843 -752581 -995941 -708098 -147493 -155953 -424224 -127951 -972197 -768175 -839302 -392032 -774556 -584547 -686864 -242526 -284773 -140423 -202058 -378182 -440221 -412999 -593164 -10397 -339014 -21437 -649467 -32501 -591528 -453968 -653527 -68047 -625150 -86154 -97943 -219993 -780785 -918027 -935258 -873389 -894444 -430206 -744004 -423228 -503997 -436426 -552734 -984643 -237794 -154894 -535972 -864771 -103912 -851534 -918464 -818760 -245180 -801803 -893678 -910862 -488968 -44277 -149890 -586159 -358410 -708371 -494490 -146056 -28001 -934802 -246899 -63476 -562784 -416981 -337985 -380257 -928515 -868570 -246887 -728116 -244322 -651432 -55949 -521047 -87036 -93…
Output: -871385292

Example 3:

Input: 1981 94 -680205 -370817 -278535 -728028 -134461 -190266 -146416 -349727 -903169 -229945 -700185 -952311 -84025 -275743 -203629 -633076 -575186 -547812 -247227 -820796 -405246 -961091 -194473 -669329 -62319 -814815 -173991 -365955 -114852 -486117 -277965 -253235 -419283 -848814 -998366 -667267 -518261 -896947 -244003 -398162 -244932 -923125 -82869 -999270 -922792 -39564 -798345 -23108 -657908 -717753 -63960 -268106 -475931 -607127 -23492 -82810 -851639 -749701 -997033 -277732 -541946 -721075 -410965 -368312 -885930 -241341 -352361 -767611 -515287 -472178 -42596 -515166 -68424 -808307 -661663 -101235 -257343 -803618 -602500 -319142 -544892 -217278 -149384 -116516 -189081 -76385 -605900 -779076 -28520 -966870 -257163 -997331 -322895 -348096 -172255 -81812 -191110 -768437 -167016 -85026 -69708…
Output: -40620886

Constraints:

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

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