CT41784

Last panels of Bhanu

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the ink district of Scriptoria, someone must forecast next month's demand. This year the task falls to Bhanu, armed only with the panels register. 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 <= 2225; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 50 36 -424919 142063 666213 219811 -306672 845589 -95072 -695569 469216 -922464 -539345 386379 -160358 -939596 463940 64550 821243 12644 -511797 -358292 -927766 251335 39589 614498 93086 951614 530458 -523785 350641 -855058 269097 957365 -155332 708943 83117 -227848 684742 557306 90652 -396118 -578869 -278840 -497172 163328 696098 195494 -784169 685189 770657 -744666
Output: 3215874

Example 2:

Input: 1077 420 -292363 -331066 -3427 -68107 -736049 -192668 -939425 -629817 431993 -546957 883915 -61816 -40705 530321 -520185 -149271 757775 -769289 947930 -57349 488806 223140 -715766 -674091 784603 -58315 714917 -494691 -3236 815594 -694731 -685376 -315487 559636 838382 672613 255390 964695 -116919 -180879 293077 -402306 567073 -313130 755439 -487708 966787 -391910 769228 -690432 -527109 -820875 -473070 -616281 -982590 -708368 545844 702084 285566 -567221 -13351 873914 326862 -714555 601744 -364614 314917 -379117 -952027 -502569 -669916 405129 -525380 -142377 640872 -909315 -538236 725705 635765 -96444 -531783 171269 -169539 969186 869890 -413470 -172879 -581648 -279815 -381874 947393 97203 -599365 231841 -33509 -619861 -421428 79769 510105 -363863 -287911 -230689 -380801 645790 809067 -32525…
Output: 5800541

Example 3:

Input: 143 98 450932 471123 -166946 431509 363313 -436659 643091 714776 815434 659546 397440 76707 -107189 -382587 -67427 449074 961504 772377 -271179 -355363 -555355 129596 161809 -141400 192321 -868994 -560235 268736 -818048 -167700 963981 794820 -538017 770474 -824915 -247221 -428553 -59452 -847863 -971983 495995 145896 493069 -907672 135600 735144 -294041 -994979 -659429 -132021 -492801 -197083 -505117 168056 623122 -618214 -381643 996782 28845 952029 290397 -270721 967179 813820 -898885 418859 580427 -880372 -304620 -588159 -14336 -458835 914526 8162 426649 766198 669998 749927 -632283 567339 765593 -276225 -901044 68652 -407982 813911 25586 178079 10393 -332290 -824818 178862 -31083 404974 -635513 931485 -693232 -592245 -879891 625302 -602280 457431 -452079 -331617 -808466 -132804 -748332 9…
Output: 3071388

Constraints:

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

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