CT49257

Rhea's Windward scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the mushroom groves of Fungaldeep pays by the answer, and Rhea intends to earn it. First: the full register of scrolls. 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 <= 2104; -1000000 <= a[i] <= 1000.

Example 1:

Input: 165 105 -131730 -762133 -584384 -568291 -813318 -514060 -26967 -602714 -375358 -278006 -351309 -462657 -372035 -807259 -407131 -653602 -678148 -356703 -405430 -380354 -430714 -898436 -254817 -954077 -76486 -597044 -182428 -774416 -270570 -1138 -4424 -841056 -137863 -398343 -97403 -354454 -965745 -119029 -14685 -274178 -625625 -217974 -614092 -520768 -790797 -791271 -262961 -826917 -930629 -833393 -927512 -571708 -119096 -802092 -720227 -637565 -458581 -504997 -843394 -50455 -933028 -19556 -234612 -721620 -710004 -731822 -759344 -620241 -935807 -303593 -355403 -258804 -903518 -778892 -341655 -124377 -331855 -428205 -59445 -533955 -138921 -775511 -439171 -716471 -551675 -446960 -356314 -218228 -764110 -389556 -964878 -720230 -339277 -764801 -664324 -79171 -303752 -395109 -64673 -345291 -9685…
Output: -49129595

Example 2:

Input: 1654 1148 -676990 -555077 -653747 -688510 -530598 -849392 -855380 -737378 -398864 -453056 -237645 -696317 -441833 -417970 -840096 -16834 -619074 -992872 -486543 -618147 -150649 -343044 -644481 -904131 -402938 -588223 -461109 -386712 -868558 -342842 -968753 -794184 -191281 -9803 -592759 -112623 -320263 -349952 -954476 -521313 -826265 -258650 -844786 -930355 -157554 -314170 -57404 -395709 -161057 -693061 -959962 -448642 -263484 -811962 -154804 -877705 -616013 -361222 -632758 -230620 -593948 -659555 -696427 -290497 -579500 -659538 -695269 -725938 -803787 -608606 -173731 -482367 -666975 -431973 -689193 -277364 -790344 -321438 -894342 -311672 -41796 -455170 -928430 -959996 -237909 -785980 -117577 -348428 -237032 -741424 -904651 -228889 -881031 -189023 -144400 -36788 -513376 -385781 -156822 -475…
Output: -583967070

Example 3:

Input: 268 224 -770292 -346827 -626916 -473399 -498842 -722535 -509075 -249309 -476869 -721812 -174385 -806342 -350548 -187818 -663654 -532885 -586626 -467117 -750152 -177551 -872884 -988580 -551262 -618535 -681582 -605402 -188582 -642413 -943239 -74696 -463327 -220063 -811924 -428464 -878127 -437302 -718743 -501931 -385786 -285347 -590899 -661332 -762016 -151518 -494525 -626788 -786368 -255657 -56066 -618882 -805487 -801342 -110544 -724732 -977858 -951322 -23491 -963795 -81581 -630297 -529536 -70343 -534855 -234063 -698418 -348019 -571805 -557365 -322548 -889721 -794494 -230907 -671220 -761855 -751447 -675404 -978339 -183154 -143302 -965965 -15160 -222429 -238061 -763294 -229805 -970161 -966479 -809593 -407254 -896647 -392528 -892860 -483779 -648108 -566754 -482236 -105410 -540566 -588120 -93180…
Output: -112954242

Constraints:

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

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