CT30335

The Fixed Window Peak Beneath Mossgrieve

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the peat bogs of Mossgrieve opens only for a perfect tally of scrolls. Wren 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 <= 2711; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1155 357 622709657 266096211 224425902 606913071 6025589 101872746 796833422 671236582 877533634 888501992 790800421 560932274 757719658 169742791 394240840 29915608 445910716 305408161 743794096 634546504 292851932 311022946 38190945 901438694 392114684 724922045 833347828 924507867 919169280 398680355 429937214 698016347 843566623 980731359 126713192 542236357 293905629 64080625 79224679 832230462 605363942 140544642 765945468 508214132 687708781 905185777 256612538 567876840 816171251 666835406 396596283 493024509 894814666 592265563 501748785 60322950 611825919 319363500 990660700 147253183 997752149 342821496 586937700 551205831 979880951 592802770 894335236 862627960 604338750 208089292 542779420 681782149 828928721 983041471 153720933 569794153 90109362 600083687 216571644 732547815…
Output: 190341843361

Example 2:

Input: 1768 505 760828735 749434026 720455650 848962205 29404177 817612128 209159602 286046498 829619427 485256864 270048898 665021657 677961354 164729456 78846633 432616871 45839054 733163478 94823061 334843640 992466830 555554454 803426159 449174892 204577932 296599791 34346667 776082102 733243660 136207316 677001882 553629843 708787749 350633166 197374489 167178146 122868403 759604001 646858462 968529714 59415472 92783948 950357398 170137163 331174407 650139087 523520259 218081734 323729170 388641654 310765714 283901378 80282846 426807108 634031723 487163446 166798274 59377920 335955609 103876034 82171984 77749985 848736124 534369069 469806845 132257353 440307510 535130 909592643 164247757 972024183 239453868 360281382 176285388 980522451 784070474 684376905 480255197 714020390 672008883 28004…
Output: 257885874698

Example 3:

Input: 2617 1611 998914454 294981433 8588925 464952410 978253154 522310723 505301050 450358603 785914008 674411316 638971758 336364837 158937519 80328980 243838594 598656813 599927581 548787534 73615959 744435043 889598546 941787795 492071372 696533849 547542860 366091817 487856801 862412485 573157933 44762473 982824775 744213221 691859594 509435442 85763998 516418714 848377911 537962281 427874444 141019777 864088727 736275831 731891258 688902619 730274207 298259078 765728371 705121071 266894800 592046684 585167985 988973651 40993448 195069319 609305980 814073098 48395161 364595049 425898755 564071048 577970100 896299611 59488467 657677970 804072811 588413854 519379390 755024344 238648211 739617930 206558135 584750033 133423068 319629801 845915699 906379155 63156477 228372941 43034824 49807770 75…
Output: 828286209752

Constraints:

1 <= k <= n <= 2711; 0 <= a[i] <= 1000000000.

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