CT50433

The Willowford Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The assayer Alaric has been asked to schedule the next expedition. On the desk lies a long table of windows readings. 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 <= 1467; 1 <= a[i] <= 1000000.

Example 1:

Input: 520 373 754937 843570 864522 438615 248151 486559 302293 90800 488422 807872 288701 366914 388555 741880 655604 937987 7317 768619 618043 436073 430609 691707 182384 631495 326602 221859 858011 42859 158929 928611 880703 872282 228250 683389 457716 875654 906683 73768 289156 136951 652348 98053 869083 121036 268289 331356 138715 754143 319044 192393 468229 873530 201686 28640 264686 765892 983033 821960 731131 720205 623171 446283 891438 592315 918731 516564 573373 924381 716819 912337 693721 968147 707174 571615 202525 846232 443906 317316 248214 486780 324265 463041 431381 189672 56636 813285 519736 817193 5415 511739 143564 462833 512979 451864 22722 48510 254956 396624 885293 782063 803267 417942 132760 615000 350194 67019 138029 495851 300832 193719 420394 904464 793461 460958 253590 …
Output: 191074721

Example 2:

Input: 417 396 613208 294908 584947 888595 487686 435164 98565 695339 778948 608418 80890 927529 521286 494389 528564 719910 40263 663537 596658 501859 86869 491559 219504 820535 565123 32337 664011 228927 367853 809873 35542 871146 7930 443145 160934 298037 524689 338596 645561 418166 622356 551506 382925 157882 679131 852433 867695 932170 161909 73778 851877 259657 555369 723037 54579 636966 315001 737213 587857 159453 632185 137120 940863 118136 547345 923695 850405 880666 692111 521733 17414 940048 569352 767171 328108 853532 594014 367931 79674 231033 8486 902906 783023 95698 282347 836910 808328 863285 129924 141820 143370 87553 125028 53125 713369 376830 675220 640942 631689 143080 812579 598421 712642 995841 864357 784822 266867 29916 939723 828164 334109 708078 878892 540115 223670 77328…
Output: 199776378

Example 3:

Input: 720 665 676240 179410 236977 747716 419651 639951 251165 195085 508991 681313 117581 133293 329725 299175 777127 699288 630202 430828 998513 274117 722423 156185 289137 330228 170021 804737 696889 751205 939517 775321 671811 532345 351668 341327 273764 978474 348432 586829 132888 732017 61751 459390 228587 590464 85803 40085 945830 585035 920693 344606 691010 247736 852690 955881 909043 504954 147033 814018 450682 244596 511022 186274 964433 220639 428260 410691 851572 126933 251667 497295 625939 516844 544896 47132 906423 737449 470116 618056 146064 164752 196801 118960 931076 586919 675403 936376 242890 345469 526604 318313 256159 927550 910701 97179 328076 228721 825871 696586 859118 879304 158788 162234 418689 528052 699773 201768 529125 528381 622763 397768 941650 958686 464700 606687…
Output: 323769863

Constraints:

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

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