CT31116

The Fixed Window Peak at Barking Cove

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

It is audit day at the seal rocks of Barking Cove. Mira spreads the windows records across the table and picks up a sharp pencil. 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 <= 2665; 1 <= a[i] <= 1000000.

Example 1:

Input: 2129 1008 522131 777806 354730 175973 394140 175793 276285 643840 155251 797247 915927 621941 866788 89733 488405 713556 929260 638955 447787 179936 894079 48849 535658 407897 352044 61979 629693 999138 626507 134888 296871 977321 408087 452366 693079 262581 319991 527350 946441 216205 105196 81146 817964 839158 569271 742825 75009 464774 651834 783518 961725 982609 436081 482479 582816 972544 870060 73550 593036 339715 344319 805949 420924 110494 78593 964332 977990 872449 417312 902716 291619 379407 968681 80351 33679 254939 410071 729168 416924 727112 820195 902409 276700 764576 720829 358313 963845 95902 14203 438145 807258 799292 920109 520655 967776 112216 518547 470237 279362 976350 248409 298257 574102 977970 698398 670637 491062 973444 124339 747698 577119 764108 495255 584460 931…
Output: 511631820

Example 2:

Input: 1589 511 935829 532119 433924 954707 934563 150522 260919 699489 453137 907449 693706 531607 274326 294635 829902 768272 307702 46865 680691 515875 313319 851152 40674 612853 811020 138169 829933 651629 881447 526705 436496 648976 737803 921116 363269 52806 981558 954465 384949 144008 840892 779936 631247 603202 698642 136748 264846 280346 231330 462196 734339 893538 320229 700172 981550 266250 968194 987557 336303 352671 166500 685638 385872 664770 544920 934732 639231 747825 618378 972028 823927 958723 433778 488646 298823 612084 589146 236475 262636 574255 732971 521507 161733 242859 470571 100435 914243 165863 75541 195817 550650 892538 33737 805310 294431 148426 393090 598324 756472 554651 838500 216827 409510 766252 783602 663087 276427 415844 397616 171769 490493 870915 108809 27919…
Output: 264924857

Example 3:

Input: 796 539 886110 921560 670635 301329 187154 896774 342626 357765 755246 180559 932089 958684 486476 896109 180063 465219 911971 48073 728992 144262 955359 107184 489432 45473 26211 245797 365339 738432 768727 939495 988159 812702 897465 981259 267600 545589 585311 501415 599843 636512 234602 540572 652808 520378 914951 675118 242687 84922 203052 191607 943846 524983 636016 894262 839813 76270 655976 830600 776665 444282 436062 138254 216680 850838 526529 915375 672836 467573 307070 596806 935777 928851 945633 192214 378656 754387 346431 17229 439576 8208 290195 609435 221162 784924 405386 302991 558342 439935 146731 60624 127778 969871 906732 462466 62245 524422 619662 448470 480929 336316 607837 135753 388916 125977 284899 564647 145042 314928 605066 29252 979952 267882 192535 928232 91399…
Output: 263921830

Constraints:

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

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