CT34778

The Gusthaven Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the windmill fields of Gusthaven opens only for a perfect tally of windows. Jessa means to find out. 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 <= 1375; 1 <= a[i] <= 1000000.

Example 1:

Input: 1222 1003 805827 427088 292907 500413 917432 261428 453718 741358 693474 631885 143827 561000 283723 153563 929963 732013 778934 715671 433856 278631 263591 30572 363946 360715 131068 80334 951986 219624 978825 631996 158506 481492 268958 974697 454345 21065 259554 219066 422897 271171 932662 373502 709742 725696 225016 426203 3484 317578 48119 283669 791418 506705 650851 893446 276393 449573 347658 305960 352304 31844 383305 219600 549528 794669 67808 790382 647934 501012 198004 704037 283039 876633 794948 20518 671483 824471 881379 992089 624297 395826 943625 7310 559286 525055 619910 358697 162150 231366 747762 144718 692209 678918 373904 56763 827557 643834 715940 673833 651692 552993 396697 983911 474745 233646 524346 230051 912637 483504 523335 642521 168110 204654 331989 53547 70650…
Output: 523588393

Example 2:

Input: 547 36 706963 598076 939898 156487 381944 417722 964442 53290 704588 260691 244640 654643 436183 572377 15516 409278 794301 122010 895503 686960 940806 152 107312 868421 611216 624813 439792 358520 215763 228067 188140 502022 385601 71712 557067 78489 139713 108389 788537 108355 712199 132670 552842 765393 86829 969392 947645 745414 822065 335481 719519 105710 421364 974032 807356 710141 78237 335154 701493 426012 536799 56007 39091 403650 221051 922902 826566 913296 580765 222379 129686 360340 407669 75619 582189 868502 828022 962696 265531 663153 63513 173464 416529 45535 303955 62247 514503 84759 553892 338288 20832 122665 234726 136578 643868 193987 894343 793889 237273 412546 828069 553628 403717 117601 723754 976370 866427 538069 765852 113908 235870 824164 159543 460031 773113 26190…
Output: 20748348

Example 3:

Input: 1147 221 981964 641035 885594 760061 536404 1900 420497 6365 850146 993213 967857 122743 410562 958516 425891 786491 438636 605968 769151 117820 785674 820730 736012 414931 752397 256751 77355 547096 863520 996797 145545 750145 905453 169730 200561 990856 496056 779450 533847 650196 246501 680699 938593 406650 38368 885874 674341 423716 182985 593241 103311 894208 991691 624567 173994 171062 739287 692207 713387 199003 797509 869792 151794 277856 826493 156814 549377 481360 383321 340120 88810 490098 569753 936463 572797 141311 76199 841704 242806 595952 669329 614516 101141 199106 996661 247786 76257 64636 558462 639014 275060 314283 483755 677036 233680 504355 974674 1403 48743 833656 273242 667980 339064 795149 473282 84219 149364 431405 630844 136737 430109 987779 315127 652381 389599 …
Output: 118254779

Constraints:

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

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