CT44551

Porter's Brass ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the sulphur springs of Brimstone pays by the answer, and Porter intends to earn it. First: the full register of ribbons. 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 <= 1210; -1000000 <= a[i] <= 1000.

Example 1:

Input: 747 181 -708665 -914977 -271061 -928106 -163158 -767931 -236151 -845885 -468842 -292452 -45496 -321002 -405335 -762611 -264224 -838028 -253308 -300072 -893046 -412489 -192526 -984194 -659645 -683886 -518452 -837679 -525689 -770772 -771949 -140343 -675673 -952864 -935779 -531289 -539646 -61487 -210410 -613198 -708553 -232777 -433756 -824846 -696643 -799605 -355632 -21762 -19723 -588900 -831539 -742178 -468669 -315210 -269836 -964980 -91062 -449912 -719036 -121282 -147647 -214427 -342095 -548706 -549801 -774364 -193139 -292955 -339481 -272416 -184122 -924 -703870 -541850 -435910 -42272 -709122 -557013 -554533 -859247 -579157 -590369 -853876 -566424 -939377 -844045 -204645 -795505 -779111 -50638 -81697 -38359 -248516 -572265 -223488 -168353 -304009 -475213 -91642 -841412 -974 -440169 -157559 …
Output: -85660670

Example 2:

Input: 977 268 -300925 -771702 -167908 -761136 -566009 -884441 -838400 -931719 -967351 -697895 -935377 -895999 -995115 -490736 -761521 -420397 -130865 -491441 -125276 -825106 -289655 -463879 -907542 -68249 -288467 -24264 -197968 -966324 -535671 -840826 -885972 -290355 -306822 -399652 -370411 -9624 -245180 -695993 -68973 -790754 -710627 -972951 -91573 -537603 -767888 -215153 -338664 -237856 -534919 -581736 -164999 -77288 -517746 -713084 -386374 -725302 -345674 -101604 -770387 -121024 -466628 -575481 -297953 -531528 -725977 -623049 -749164 -210759 -761033 -837080 -835196 -341068 -761412 -715683 -979948 -614974 -74518 -739111 -315027 -673193 -202327 -324916 -736867 -340858 -807210 -244520 -214187 -620041 -763498 -630635 -265526 -857261 -572154 -502345 -737015 -264755 -363999 -797846 -636844 -736104 …
Output: -132287577

Example 3:

Input: 760 285 -225276 -259435 -117484 -835410 -853841 -991498 -911152 -441440 -323340 -100063 -908485 -68418 -436873 -59209 -957618 -443793 -74723 -258745 -468490 -424653 -499921 -237301 -645355 -962636 -777337 -588266 -711449 -73975 -113385 -351243 -70829 -611257 -843845 -311748 -136841 -752843 -38091 -642958 -558011 -362726 -593167 -752640 -305103 -741032 -554996 -983744 -940637 -615589 -701433 -835029 -575253 -551882 -100293 -511491 -823024 -637848 -709758 -113346 -360453 -637604 -628006 -676127 -292978 -284013 -452069 -397527 -340267 -321033 -755748 -837444 -350287 -858778 -988407 -915167 -212740 -211431 -560480 -401685 -867291 -788998 -481855 -453597 -44365 -684799 -202584 -174514 -246138 -417301 -59176 -311561 -746208 -400538 -908052 -685001 -85931 -981213 -330304 -194388 -86304 -261879 -9…
Output: -137376321

Constraints:

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

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