CT43491

The Celestial Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the ferry landing of Crosswater as Ysolde unrolls the day's manifest of panels. The tally will decide the next shipment. 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 <= 2135; 0 <= a[i] <= 1000000.

Example 1:

Input: 614 42 664780 241193 338209 461343 593637 34381 469521 622285 952902 762165 343729 751113 542778 702145 864443 803007 60769 639759 387168 274940 759942 714266 88590 340742 248051 591537 669038 171693 550049 131279 280543 129784 89691 831110 859311 457628 744322 688227 562640 628084 492791 5069 472533 391685 58791 600734 498889 303987 595456 74277 96702 591057 813984 169041 152352 693239 773180 223576 29160 313732 287509 186563 831227 961594 804351 210343 387875 514372 206744 763046 420099 409549 290035 136274 79347 725730 934560 28116 321563 135096 932659 460771 751913 590450 667120 455677 35812 654936 414017 44532 83011 512767 598329 760138 246271 481930 485317 215667 680386 967481 184268 139826 799500 582324 8054 591317 35142 20054 669155 259805 923227 440184 857474 897434 638165 112492 …
Output: 25252401

Example 2:

Input: 437 405 121564 858039 347566 841159 784177 2198 404531 37589 341516 793721 257063 958842 280004 469190 541728 328720 387441 824857 227681 318822 356516 861961 351643 400528 233610 567355 849138 56889 337625 236269 661371 888325 953647 7866 368150 97410 946089 601558 38103 773496 526842 57740 988014 78828 336242 176914 731859 205191 697156 986442 953697 919512 944085 721396 84382 961395 735984 931860 275636 434051 556714 537837 81264 360864 323432 298678 873358 568129 641383 730759 598242 910168 277806 762135 689042 200046 892539 251835 285056 953707 244537 810662 546076 941136 688089 100687 249515 183076 844058 825835 343440 457213 556522 496308 103699 676654 858335 248414 899777 295366 571554 529632 239832 247092 318671 211650 249543 163571 64730 60961 651345 13756 397793 223995 167602 86…
Output: 206018160

Example 3:

Input: 2053 1016 599835 382914 695528 251216 672305 973694 823942 63158 298230 910022 565616 209876 341848 560414 40563 710972 206743 745791 163734 523280 176590 37122 376972 725397 278709 271298 732763 18639 870870 575983 235102 932955 744760 971602 733906 83664 567584 521067 617440 506616 889682 503076 405232 548295 975141 487036 171326 508531 303521 916549 987232 562485 46369 740789 107190 233538 920970 792334 348224 882361 100955 8753 111204 184260 770133 467106 261619 162800 698635 71369 202059 853285 231833 536651 830245 506640 117974 252087 540029 730941 5651 980373 900096 653358 878446 349261 204321 189801 194078 331499 417812 492394 914494 732995 424167 129647 714011 164266 886724 642903 36749 864926 75055 53573 647986 177736 460497 427498 677531 65233 283603 483711 726432 680351 935442 …
Output: 513509107

Constraints:

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

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