CT31989

The Glowtide Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the lantern reef of Glowtide, Admiral studies rows of windows entries. One clean number will settle the guild's oldest argument. 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 <= 1519; 1 <= a[i] <= 1000.

Example 1:

Input: 1517 1395 374 300 895 134 918 543 743 985 531 356 412 528 955 173 921 999 470 386 346 387 767 196 941 896 511 851 725 444 264 531 278 261 196 776 97 59 985 317 549 973 565 897 462 871 78 813 945 867 10 90 540 117 468 690 296 604 177 957 692 306 527 198 693 884 507 268 18 477 270 36 513 539 334 88 773 926 101 24 978 201 221 264 539 813 571 346 148 968 621 735 517 728 759 567 51 462 194 580 876 484 337 107 538 922 23 407 80 342 214 108 347 749 5 762 541 973 442 438 807 186 485 691 923 370 225 135 767 843 845 851 229 460 624 733 86 496 816 755 58 360 161 947 801 309 968 909 190 811 753 312 146 303 261 708 311 680 537 567 93 498 864 461 363 102 883 187 908 436 721 270 449 139 339 808 615 721 218 509 980 712 560 574 629 868 178 747 57 71 887 670 269 954 530 87 356 406 137 465 71 574 854 591 693…
Output: 692265

Example 2:

Input: 1088 889 511 6 872 525 75 881 452 739 765 554 14 793 226 405 878 98 46 335 114 291 167 38 579 141 758 168 242 348 83 725 699 371 689 351 477 439 301 292 719 874 782 285 507 790 771 337 208 429 211 411 971 93 804 181 1 208 780 359 517 260 114 1 895 358 569 674 683 947 208 432 829 413 166 781 601 291 426 288 71 109 847 400 755 266 98 721 89 703 677 990 368 924 763 84 548 76 55 8 770 467 458 261 426 973 654 378 328 852 136 634 547 627 674 27 302 10 55 697 680 888 448 776 668 313 839 419 352 339 442 531 87 208 262 348 970 562 219 849 130 756 443 797 694 750 252 950 941 480 270 530 940 387 379 802 780 160 956 310 311 766 769 316 950 740 874 434 788 232 842 29 324 872 238 655 59 952 605 21 565 811 684 852 329 537 697 42 350 232 839 127 415 987 627 814 720 197 865 999 780 871 267 199 113 100 816 …
Output: 456288

Example 3:

Input: 654 172 328 629 246 987 160 13 732 217 53 677 924 616 7 879 317 642 419 246 86 53 838 407 97 687 587 376 668 190 802 381 987 911 577 595 880 441 626 408 414 575 837 483 519 429 879 152 185 381 720 608 721 150 825 2 887 976 117 968 421 327 167 559 84 760 519 939 878 924 310 814 685 721 877 59 873 902 956 294 17 806 795 49 6 247 555 24 794 508 85 926 413 254 174 635 72 424 162 87 869 875 421 175 850 717 187 131 169 286 478 409 601 986 17 813 416 934 623 248 505 230 738 612 469 51 745 776 279 7 829 421 993 276 100 833 489 396 790 48 555 406 279 848 264 640 18 414 788 629 971 187 709 276 145 226 497 433 895 74 805 661 443 793 228 233 878 371 975 223 452 160 767 279 762 824 686 129 391 291 211 720 544 268 663 648 554 664 245 892 180 822 520 793 837 228 521 334 740 1000 629 518 405 969 775 770 8…
Output: 89923

Constraints:

1 <= k <= n <= 1519; 1 <= a[i] <= 1000.

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