CT33856

Baker's Fixed Window Peak Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the dune sea of Caravanrest, someone must balance the workshop's books. This year the task falls to Baker, armed only with the scrolls 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 <= 2363; 0 <= a[i] <= 1000000.

Example 1:

Input: 1196 219 898312 989144 864608 280666 192956 799714 541660 765609 351833 972072 473670 321862 590874 549044 463326 456580 874767 546768 117626 605103 398700 528814 946969 298867 360100 902497 778058 913877 276937 117012 735138 557225 196700 116815 994731 278686 6242 125244 304200 737021 778552 348802 648084 839195 110681 753219 108034 59234 151913 720071 931309 644002 745297 546012 51210 172558 990714 718912 489287 353024 69191 643083 834220 708855 523609 216311 274886 8024 841563 65392 170930 245533 539733 839430 240498 331631 643991 289719 14669 281601 199154 445229 162299 675887 583069 123309 403536 227755 791624 414439 909971 821232 244363 574222 201883 500895 725430 687186 436330 254492 624083 660873 783649 284747 280491 156870 666096 419862 145252 17948 704046 42851 503560 419645 9697…
Output: 130033183

Example 2:

Input: 589 471 145270 927194 676851 864568 687930 273015 921748 433956 398200 35389 811420 770091 261811 136690 632889 451433 445191 337170 679231 890032 64103 437835 776912 922921 841197 771043 649902 94389 543912 507090 818561 993115 51542 902387 764835 239050 335986 806644 805233 705527 902548 332012 278744 38386 632894 410494 916179 888797 749153 704049 964417 141895 32946 703609 633340 741190 703457 100770 147826 715741 556620 873056 529790 454592 191237 179903 916072 787414 607839 183695 311979 501856 667131 890297 566346 822531 589307 893266 662106 725857 477978 236900 661494 670893 256417 849978 495173 825543 148170 553174 901272 517633 691261 322729 854628 869636 579531 923573 386297 891252 624418 327626 627779 430618 236000 467346 225390 360386 630559 243808 651931 303924 162405 836921 …
Output: 240877720

Example 3:

Input: 1083 1076 773112 94239 99592 511268 856307 767978 230484 462122 257561 364941 68348 110166 245312 867579 944980 805872 275075 177447 689263 105928 597577 860734 999628 296831 84502 9301 720510 515314 928073 179209 754530 922092 914523 844542 607291 129110 618014 763949 732319 522007 384167 292967 511610 853479 134385 380089 872740 216807 531781 699177 807280 565714 98456 157144 304688 900687 239343 86096 335807 288409 709146 180382 237434 284192 349680 849014 99138 84353 746754 484506 430213 417830 52054 878665 589150 1851 13910 23184 31606 846187 184499 311827 693862 1564 648238 894670 701029 776759 675691 410336 580824 198562 853191 645849 467181 235280 691724 364949 597151 278152 253407 840455 417054 619965 998653 844575 536025 817342 677001 630406 686279 471634 749476 47192 825878 1016…
Output: 537604042

Constraints:

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

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