CT47889

The Chessfield Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the rook towers of Chessfield opens only for a perfect tally of panels. Yara means to find out. 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 <= 1390; -1000000 <= a[i] <= 1000.

Example 1:

Input: 90 44 -416375 -398514 -554149 -632266 -501803 -907719 -300707 -359341 -157421 -814633 -476306 -895303 -354472 -828252 -24406 -707714 -400349 -740321 -390598 -725537 -593365 -490834 -412872 -749740 -587472 -545009 -763769 -342780 -888813 -196072 -770026 -95610 -203679 -170602 -821030 -557996 -302394 -131534 -604158 -461782 -458103 -573042 -561857 -457644 -933142 -627898 -340084 -569042 -909738 -969353 -316384 -982418 -618172 -857500 -228637 -522728 -536727 -599906 -788656 -84067 -163690 -25673 -243547 -628920 -148188 -610631 -777736 -799141 -775361 -213138 -844633 -133935 -679506 -875669 -44349 -794924 -440406 -112597 -249156 -458461 -888409 -401671 -393344 -905726 -921293 -98996 -353537 -382165 -677988 -770949
Output: -22241288

Example 2:

Input: 376 295 -370439 -859469 -101106 -441622 -932858 -943963 -877535 -760110 -815570 -227168 -768536 -58217 -72049 -926879 -13835 -750132 -791867 -432230 -55950 -951502 -950490 -111583 -297401 -514988 -918797 -314524 -319450 -837808 -24146 -340246 -34972 -136824 -599778 -305339 -169544 -225722 -824242 -315497 -608394 -36737 -587533 -579447 -261477 -887555 -12416 -163151 -490399 -547910 -300405 -594413 -63766 -245009 -279699 -410186 -759697 -771334 -767507 -958763 -437738 -893562 -819223 -393720 -705794 -859926 -387849 -356046 -249204 -634944 -922267 -449282 -931899 -456055 -435400 -925862 -102860 -772666 -833260 -154800 -185622 -433261 -591141 -659340 -284829 -609319 -498316 -811503 -510742 -353648 -198181 -642920 -194898 -971500 -126509 -566467 -882443 -422182 -755057 -457137 -560890 -98380 -7…
Output: -150732741

Example 3:

Input: 234 219 -246393 -4398 -688621 -586282 -335553 -199703 -889611 -141867 -596365 -535122 -805883 -805070 -779437 -492709 -247838 -823971 -28645 -367680 -503067 -945485 -377071 -736742 -640150 -220139 -868140 -940439 -41746 -360902 -483790 -91394 -126527 -483807 -707954 -824453 -997790 -995486 -424156 -26413 -759571 -373642 -976798 -441231 -668891 -360006 -897659 -579401 -679558 -629331 -691665 -864816 -389701 -962376 -861668 -382358 -877228 -681148 -879963 -781807 -729577 -279316 -801125 -209545 -290685 -219746 -743735 -140082 -826840 -262185 -260495 -536694 -799089 -738783 -279762 -118359 -731927 -275718 -666611 -212542 -595618 -943809 -35907 -281686 -578252 -266683 -930214 -52063 -183670 -369312 -119321 -495154 -800097 -472494 -861953 -377964 -119211 -956912 -311509 -642347 -329069 -55607 -…
Output: -114476278

Constraints:

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

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