CT56508

The Fixed Window Peak at Barkhaven

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Paige the paymaster watches over the cork grove of Barkhaven's stores of ribbons. A careful computation stands between order and chaos. 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 <= 3757; 0 <= a[i] <= 1000000.

Example 1:

Input: 2368 855 569109 461363 878536 595392 615738 643686 582630 194208 626104 773875 647799 586453 30139 405718 337856 350451 274040 126249 165727 113150 890442 786398 37128 364090 307166 890537 570911 606745 418914 80407 791442 841780 395400 617935 447154 236248 135961 863398 37048 701235 504148 180201 627116 724272 714469 604523 204452 149658 538277 83297 44703 517041 226648 733444 940267 879560 212638 844542 610467 155724 597008 971051 833549 784586 826239 732426 212544 856214 448987 352758 330240 311726 616937 585650 386155 725856 638600 227938 351850 237220 262148 970021 311208 234069 651950 938252 138378 737900 627547 774303 415095 740427 796366 435257 972464 32806 294127 820484 595390 355295 109396 651866 665355 874689 356423 357855 660850 641794 925168 663436 835477 250299 784544 933226 …
Output: 439839810

Example 2:

Input: 3197 2793 812980 632867 190783 548796 459314 963614 690162 290819 638084 76539 855267 674289 149921 870163 903480 946193 396701 437649 546565 62137 892001 204769 223748 477412 922087 591801 254330 891424 67417 621421 916225 768751 910730 80116 263758 940997 662063 196324 487302 699638 296883 414228 10442 493749 280895 695775 462796 650480 685914 498978 579723 597434 634982 934697 958680 124598 985072 732718 323399 849307 284885 581161 891369 721922 556728 799054 546216 281884 764738 972102 690613 634551 593677 624836 91013 825903 425901 896842 177292 27986 512113 566234 866884 38970 573178 2879 949502 473488 426236 640410 975979 655048 888478 150762 499903 520728 297118 750896 103257 63775 917903 200775 512359 844449 499648 565906 988982 169488 296066 507758 538961 846870 888768 134070 244…
Output: 1425762005

Example 3:

Input: 515 290 922928 917470 238421 781512 712823 403389 880709 965830 466318 753491 642260 122753 987202 25108 10943 527983 669886 381785 590337 749165 226222 544511 915925 783547 868987 914091 165976 380716 77073 254962 655705 398435 686899 973828 407891 563892 965398 252525 739552 602772 960466 122573 610219 467773 714546 15124 439893 236903 748435 679551 545483 451984 763914 194403 241126 366867 910442 851184 889868 130253 548503 988925 273807 627362 642552 315648 144856 460901 309977 474316 12271 807764 21156 757523 169252 879251 448062 170007 423380 821401 9369 179407 838407 373253 305106 965338 622551 541512 803574 523499 574035 768784 72950 629574 411299 5447 677123 781639 799733 81497 978886 245822 589261 782396 762475 497993 415261 771103 417205 789552 401560 945369 5818 481937 879097 8…
Output: 146418688

Constraints:

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

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