CT29937

The Fixed Window Peak Beneath Bloomhaven

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the tulip beds of Bloomhaven with crates of scrolls, and Squire the log keeper must account for every last one. 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 <= 3264; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1315 537 375139729 673710594 496937994 744340194 574440437 687475440 278858178 635824922 732557493 982506195 888883813 326294880 25531763 864418998 252483175 662184536 16383520 94630054 987160696 115603458 471377830 557722560 75552011 755572910 629373571 466157095 575473394 413258242 639952250 482737078 485158932 902258185 907069401 896667955 687500760 84716091 301683646 190679192 724299163 40280129 517903949 91786699 951195562 740822661 467335136 29064119 654864848 904661999 772080303 771448954 917382449 641980798 974753497 659978360 939662083 942596860 862395794 744904772 482086491 248890942 851217925 266340341 435448098 483472410 164200456 988220743 771467643 283122934 729211057 818576726 597709876 707801568 827476074 917504730 132831777 645565261 431343288 92862107 582688229 778962041 …
Output: 276369174201

Example 2:

Input: 2245 643 293785832 5470151 935958666 47859062 680771128 864294758 311160016 266294330 398851363 812046652 297134738 855107884 884393482 356349506 98756307 116460814 627874833 226740107 65149123 104282021 281338834 121562261 342458069 863488691 247827732 97024467 867747352 566514494 883453135 550470575 384919387 508307627 343387202 288379279 731059261 136609704 731722532 767603645 252331151 597256441 209306589 927782955 15827511 224822847 49677113 347619330 973118114 186776967 46229059 130541362 722941117 64963752 951963783 391264580 435359569 473651591 991771659 252858043 662906624 841543484 739705690 937561314 511211590 760012175 887572532 205995142 403586072 864992867 494446094 142817662 834556808 491590120 700728833 760967651 236375808 43691224 974014459 178492506 463374309 262976197 86…
Output: 327745792035

Example 3:

Input: 536 28 911550985 8052546 714960348 209079244 429393118 290124410 361987692 636981646 544925893 582407387 903786162 536505875 641012952 197381593 192011636 997906591 819104723 799886108 747634434 962958248 44907897 522809066 915152228 292170290 616793076 617620233 315569693 47264076 384415529 21363828 171038440 244276755 935107792 745253727 682604798 466918850 428670342 615756215 889382409 77811545 757764311 84180171 732656968 900023140 432154456 399234120 300519533 344661561 300426132 254318414 16762909 531832167 48881236 646822679 704471771 817937061 630957552 818116889 605725108 332937751 733111047 863304121 697589007 361992833 704877320 754415673 952934267 31425641 348297933 715311622 189345554 461663213 805423180 368080625 453265723 230359992 940742883 762220241 341702158 243584054 882…
Output: 18057576613

Constraints:

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

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