CT39646

The Fixed Window Peak of Barking Cove

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the seal rocks of Barking Cove pays by the answer, and Corwin intends to earn it. First: the full register of segments. 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 <= 3851; 0 <= a[i] <= 1000000.

Example 1:

Input: 2606 1223 66417 517701 177692 353181 904414 998582 101045 496520 244439 140510 74118 682531 169972 759195 96782 868553 728766 557718 418443 969865 364310 210439 7916 753964 407901 70188 273307 216213 377232 187487 157533 750477 118701 423244 416436 438124 579504 343106 393059 439529 291637 203691 925803 797078 513351 970365 545490 194404 515952 736189 591712 361905 841636 31419 245895 911217 368006 868778 748138 525141 182280 416306 856546 693387 674831 465702 679491 978000 841869 132441 902993 284482 715773 670870 758276 552240 690402 411756 411381 881737 630648 751446 721144 831638 350915 857867 182139 373816 265087 170400 32181 449492 277316 648655 383029 641829 668806 233508 739964 931101 614640 309722 105269 539722 78782 708043 334025 674930 869028 997668 32785 493351 479931 244811 88…
Output: 613412680

Example 2:

Input: 292 101 289315 133082 340265 113117 84731 911525 550343 412317 767950 852553 738079 837207 224456 266834 171350 584364 728603 836317 832966 796350 416176 482706 371770 417337 473543 70267 388267 970217 652373 436692 394840 442925 280279 747173 76439 901093 101395 572576 650634 367187 664153 498334 533630 337191 541404 969660 339573 100291 757065 375158 111297 386401 947964 929226 287942 905941 847832 585936 571677 645289 68070 537245 740084 587287 999673 976660 422059 891190 198169 783900 548174 586624 44993 291162 763882 300125 243648 442182 837014 48373 513975 821817 578743 804582 531852 853621 487229 973093 569124 510873 897852 827706 60077 974262 796977 208199 21849 594632 998052 160831 942386 956849 104603 117232 61886 677768 568990 825777 525958 195071 189952 365373 690489 926445 410…
Output: 56826045

Example 3:

Input: 3095 1045 456373 936666 846742 358477 439777 386790 846221 148577 148023 836891 51428 406568 792390 186302 112091 117383 720095 916200 992371 186032 30848 334596 396410 869762 129159 508944 221833 790167 11692 638502 583529 493864 417384 187524 83763 61641 372153 123684 795647 896940 266206 254991 770121 179995 374270 461088 399199 476498 262860 905934 618558 753802 541314 182132 943594 40996 196315 714258 126332 332274 291217 309052 111065 800634 926181 903646 959646 989971 775294 13741 213479 458139 553184 835346 959726 648481 555854 953273 337744 989699 981806 918966 634788 512213 999847 853574 110827 464314 349269 974814 865235 617794 893277 939278 956281 813795 576584 941058 575208 229199 758932 927531 234590 354046 26059 268146 325255 349401 967450 196779 93862 5044 222817 521004 311…
Output: 544969042

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Fixed Window Peak of Barking Cove - MEDIUM Coding Problem | CodeTikki