CT32542

Last stretches of Qadir

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Qadir inherited the studio at the seal rocks of Barking Cove along with its curious bookkeeping system for stretches. Time to make sense of it. 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 <= 2494; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 136 132 -186201 -429094 777444 347807 -464955 -606759 216517 -171441 653675 -21452 -639468 659073 -480756 -329704 15078 -493172 53461 -543549 619354 667558 448715 -885647 -536534 957723 181152 -405312 -203889 -931733 64946 -861248 594509 585972 -799015 -948525 602221 -976779 182611 -277464 293830 -413026 -107405 -186531 845239 -217601 -940068 -187502 -546888 849004 -56744 566138 122289 -984558 -422594 -28239 -3049 -595452 -178130 847154 698925 -624771 273143 19822 -431258 -244290 83033 -608186 -961083 -982762 -940132 -454670 95417 474170 -820087 485751 -413315 88734 689243 -535229 -875357 622589 -460844 -118034 23133 243088 -536833 973712 596125 105695 463390 -918238 536528 -951508 654707 467187 -803855 74606 -985713 690616 -690932 -97199 678757 50624 -212235 -159490 970084 853050 734838 -…
Output: -795112

Example 2:

Input: 41 2 916848 705275 191870 40295 -951833 468983 47398 -871071 -519726 698123 524772 839662 -730847 438484 -246656 818265 740951 -701620 591160 329585 -868750 -291710 584533 -450608 123710 559874 -436519 -290365 199654 720705 -188666 -101604 975367 904903 -720924 154023 381674 -827640 -473260 -422607 -187251
Output: 1880270

Example 3:

Input: 1180 1151 200375 977463 157388 174550 619481 -761158 991961 -300052 277074 -732482 972233 408937 500385 732787 823453 236011 870004 58213 409424 -733108 -628716 -946178 947489 -15216 295531 -6831 565925 -666931 982083 -2439 617812 -315959 448359 838121 700052 455037 -173153 365289 -472448 419257 191127 -312817 -909212 -931588 441093 516733 -680210 -949780 711040 405487 -456998 343973 -935284 -468825 345228 -464668 289271 -975244 369835 22972 698648 788507 -254996 -294668 72548 59096 -736768 -288358 -938549 748105 -530400 729101 -818287 -535200 434409 -143866 -381175 471068 -979075 875127 -640162 -231733 -816745 218196 -331691 320462 -326896 131924 439840 -419345 521384 98779 636068 -705381 -609572 494632 -961395 -706161 -368720 -842356 -384568 711445 -525930 -26110 -327961 903206 146536 91…
Output: 17887769

Constraints:

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

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