CT56394

The panels at Willowford

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the river town of Willowford, Milo the chronicler keeps careful count of the panels. outscore the rival chapter, every figure matters. 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 <= 3772; -1000000 <= a[i] <= 1000.

Example 1:

Input: 333 215 -533523 -690188 -92709 -687374 -837952 -983089 -629636 -839725 -98182 -834844 -695867 -301917 -225480 -723806 -65528 -433344 -733292 -841003 -759468 -659202 -559760 -661453 -190379 -957829 -261430 -284964 -710679 -987761 -131622 -685800 -766821 -290307 -653659 -936419 -741227 -984030 -339576 -842148 -876281 -53775 -175109 -184018 -610009 -412755 -724046 -961621 -657937 -486533 -71149 -205256 -551012 -53426 -538062 -221840 -152912 -909128 -60499 -506048 -13858 -3220 -401004 -38102 -534392 -852828 -266370 -310459 -360369 -586581 -251295 -964091 -948854 -192990 -425777 -618729 -588839 -692283 -938947 -932291 -899961 -783977 -336702 -518740 -990032 -480461 -466174 -797741 -969826 -200623 -856483 -376784 -387072 -906084 -648603 -557481 -695226 -575742 -407085 -461110 -405107 -260008 -43…
Output: -102176044

Example 2:

Input: 860 377 -519397 -452806 -936790 -970231 -280609 -948807 -424364 -104332 -449644 -827050 -537162 -76712 -468306 -364623 -794726 -135897 -399085 -741387 -704085 -959639 -763803 -140768 -231063 -870744 -832036 -124136 -797724 -553770 -783383 -754440 -579058 -92086 -101707 -373750 -53236 -519172 -862038 -183970 -246386 -503339 -176034 -690729 -745304 -240752 -489122 -157412 -371574 -184933 -329449 -911444 -554755 -452991 -222009 -227799 -972724 -998827 -671859 -804200 -416721 -734893 -987642 -978820 -942185 -925160 -578776 -557302 -233236 -766714 -35613 -36935 -531467 -73746 -70601 -12201 -443180 -396297 -487821 -124785 -345121 -535245 -450333 -116964 -154883 -10179 -491659 -748660 -734501 -289099 -809065 -44578 -954665 -383591 -240826 -967166 -333326 -723584 -680211 -599858 -495762 -981814 -6…
Output: -186906889

Example 3:

Input: 240 235 -419811 -629980 -667909 -52228 -184167 -65935 -61481 -149898 -811680 -753497 -170541 -546924 -778373 -403555 -158204 -663326 -168475 -687154 -891165 -241753 -614616 -549543 -245210 -996878 -834992 -759673 -660064 -272982 -746775 -416046 -805126 -777152 -584542 -663347 -991122 -558281 -613539 -179103 -368341 -322823 -177600 -907082 -404642 -33873 -8372 -398957 -492898 -664590 -483587 -642603 -256196 -429773 -828949 -489784 -354725 -862733 -36135 -50208 -972343 -258121 -789106 -754243 -293344 -979830 -993525 -732679 -908010 -208556 -570866 -683041 -987395 -162540 -776894 -154632 -119604 -289306 -309734 -737440 -528914 -625154 -655533 -999714 -799462 -164569 -263585 -832934 -787170 -133181 -390437 -525639 -466814 -486626 -246480 -949245 -636216 -652880 -285392 -995050 -799584 -187667 …
Output: -115578380

Constraints:

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

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