CT48735

The Fixed Window Peak at Bloomhaven

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the tulip beds of Bloomhaven; Gautam weighs the day's windows manifests and starts the calculations. 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 <= 2289; 0 <= a[i] <= 1000000.

Example 1:

Input: 152 61 240045 980431 844561 699115 125152 790557 95096 267469 167862 618148 468526 617187 496239 228871 830614 28523 955104 713909 841494 795672 512130 279532 707891 422602 426765 141002 481847 940230 713029 360213 232017 986490 413586 981522 44572 755109 13909 110603 932389 530764 212131 934685 641643 252554 411778 323997 937274 388106 479562 605989 777649 513964 987467 88351 399389 577795 414497 357830 627263 20874 756846 302713 876082 600728 697719 885255 85727 821193 11024 138535 799605 644130 878295 443046 165579 986254 922762 588967 787375 551900 335573 907708 990979 39454 92760 227800 623058 710294 788367 467805 297960 221311 987075 495452 923043 72612 311683 707208 272342 2103 456835 148354 561782 116431 641265 99962 412603 197921 291101 674236 327288 460427 874057 225382 576823 40…
Output: 33325333

Example 2:

Input: 139 84 612360 203678 331929 319695 692358 652589 236622 306663 250720 740465 286721 437713 802420 56911 819645 983434 275852 836618 749306 47882 761565 484234 422764 708391 528887 390646 379739 220186 572640 953572 329233 728321 238465 91073 664328 249016 585041 271525 264706 53268 729982 9484 90713 535355 271348 653895 805381 962098 273432 993285 904883 261801 304347 178540 885920 591571 653989 217431 533802 675492 583518 101920 972632 705626 444470 136299 315142 988188 766306 704583 890006 935558 508887 535578 321672 745556 303524 387760 561243 853669 262091 740737 13720 733340 994624 983603 271182 80299 479064 470414 94386 109011 768430 403612 616213 306358 829964 545330 554041 527686 583383 208045 89369 686246 95932 715651 318382 974927 331062 990575 315362 21460 892846 555152 616740 1…
Output: 44898701

Example 3:

Input: 778 163 467368 627315 462284 998946 811071 869472 392989 250902 122554 435906 723079 682191 89249 323041 667507 4006 325046 165239 712254 933586 899277 231685 579045 438200 399342 250104 842123 767105 245145 376412 731979 604453 777916 39881 573902 684909 619721 86956 537432 771400 968990 624271 710020 721238 375427 1321 209901 54069 308105 323782 917694 605554 70040 845330 50441 4552 643284 397693 356934 817957 582034 873130 184528 968895 754872 198627 749147 76415 383917 609716 443217 451025 414226 367376 816750 686324 670189 347619 86271 281108 14366 620771 863438 430784 13654 84869 454815 179924 674117 814652 593259 652333 703954 433120 697998 375323 365672 428369 15995 311873 796526 581857 913248 587734 625561 55885 4754 568754 561311 210657 981371 90401 84547 376325 172853 874846 537…
Output: 86541397

Constraints:

1 <= k <= n <= 2289; 0 <= a[i] <= 1000000.

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