CT44975

Emir Counts the scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the mulberry rows of Silkmead close for winter, Emir must finish the scrolls 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 <= 1121; -1000000 <= a[i] <= 1000.

Example 1:

Input: 931 454 -724577 -574786 -721324 -954234 -118100 -999078 848 -726982 -999285 -282642 -281387 -943669 -986656 -394432 -223892 -112051 -440127 -558222 -704849 -238174 -49751 -910850 -629717 -501069 -431735 -703495 -258284 -809954 -391849 -871855 -288325 -306375 -213765 -773082 -432714 -509279 -85291 -877057 -647559 -790183 -51828 -765808 -22699 -509656 -522682 -455562 -736156 -62733 -274721 -930294 -431938 -790172 -59210 -427617 -496133 -496450 -416508 -345151 -514211 -280489 -33693 -253880 -921113 -760396 -461670 -529385 -360814 -370751 -439373 -920895 -294197 -544516 -742400 -119307 -663625 -317800 -617103 -720982 -280903 -147319 -602399 -792835 -774298 -104865 -756547 -949986 -960392 -274388 -873933 -301016 -860992 -810596 -502366 -360849 -160990 -398669 -153991 -418524 -82490 -487102 -821…
Output: -218044956

Example 2:

Input: 382 188 -877313 -642150 -600212 -211954 -342982 -330302 -728083 -252922 -379262 -321006 -461741 -531301 -676839 -585140 -155727 -329015 -923158 -506012 -328973 -122872 -415642 -994713 -441624 -647660 -415155 -69947 -588212 -894260 -466140 -245311 -186762 -727632 -41651 -174204 -5322 -770589 -378524 -272069 -211523 -448565 -285590 -26954 -128008 -169033 -582179 -998719 -797304 -78234 -780631 -330778 -786661 -877141 -116277 -906498 -713261 -701242 -64676 -862173 -978099 -562321 -281675 -293049 -827526 -813909 -598413 -333020 -968270 -854067 -967799 -492887 -819761 -327775 -862773 -228200 -712298 -632286 -86768 -21006 -990706 -419922 -795765 -41659 -392703 -841129 -281542 -400522 -327977 -848744 -428171 -788623 -829106 -804044 -260728 -65277 -654342 -100254 -68659 -689743 -103737 -928138 -358…
Output: -94132766

Example 3:

Input: 147 106 -442134 -448178 -947416 -551901 -496089 -722790 -600196 -456551 -318913 -234991 -762914 -570227 -916967 -864013 -599680 -597164 -620443 -682014 -888620 -314443 -676859 -687070 -727837 -63921 -339381 -794949 -36659 -785008 -489084 -905434 -374311 -972777 -466355 -788434 -576049 -897095 -61032 -987452 -899231 -515162 -328157 -395134 -702839 -822439 -122324 -926167 -644161 -951438 -401291 -635757 -604019 -184906 -450720 -269447 -223582 -38629 -946598 -663846 -536369 -862695 -744427 -114227 -515584 -587207 -364917 -635547 -815085 -211677 -938055 -540622 -807543 -856281 -381518 -71421 -936144 -102553 -223471 -178780 -291173 -36298 -622789 -87073 -569089 -169163 -330884 -870688 -717872 -446438 -435030 -755546 -447286 -679498 -37630 -241871 -678766 -33583 -54929 -637692 -505413 -28807 -64…
Output: -50196581

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Emir Counts the scrolls - MEDIUM Coding Problem | CodeTikki