CT30842

The Fixed Window Peak of the Opal stretches

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the quays of Driftwood, someone must audit the season's records. This year the task falls to Owen, armed only with the stretches register. 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 <= 2034; 1 <= a[i] <= 1000.

Example 1:

Input: 1797 114 509 489 675 106 590 39 477 186 565 980 755 748 342 561 359 895 575 368 274 71 24 161 693 631 715 264 498 81 512 237 5 150 390 941 26 958 192 940 584 895 874 364 564 376 652 978 65 989 181 323 17 880 196 679 698 240 79 822 970 149 14 630 752 814 705 978 382 291 225 323 146 289 630 195 944 916 975 482 582 695 427 909 876 243 744 156 262 826 85 638 775 912 488 117 778 675 491 270 901 369 404 668 583 268 129 321 974 841 862 1 554 976 15 559 760 120 535 119 859 621 701 645 970 605 59 789 612 588 776 986 437 409 490 502 121 241 76 898 14 69 247 802 28 972 172 409 649 305 117 601 615 509 497 144 637 893 141 869 918 495 911 127 161 929 765 535 938 881 820 51 887 94 389 507 101 813 415 585 487 659 902 690 636 297 186 851 87 22 625 172 12 982 107 820 791 533 756 611 685 159 533 156 882 504 …
Output: 63492

Example 2:

Input: 2007 669 334 707 617 23 211 625 53 985 692 641 248 42 746 420 947 829 172 270 560 896 388 548 836 656 350 944 651 77 489 695 708 810 980 224 231 569 201 915 861 817 794 31 87 800 345 587 661 495 738 115 165 461 125 645 255 188 666 68 320 687 974 890 48 543 184 954 236 142 527 989 952 795 275 308 562 887 802 587 349 539 67 868 582 359 637 320 661 507 987 937 566 853 457 623 444 215 873 934 809 466 294 829 625 973 634 645 786 570 536 327 921 510 233 977 304 369 146 700 647 713 68 561 694 867 233 414 695 64 882 721 129 258 806 222 697 540 704 850 451 925 812 734 262 60 589 51 68 159 598 862 890 326 473 220 172 998 490 713 443 879 454 824 409 420 355 482 386 494 518 680 279 569 752 892 931 45 48 434 374 767 938 863 536 689 790 981 239 608 44 571 310 763 2 640 771 609 803 418 351 812 125 839 41…
Output: 346187

Example 3:

Input: 1965 1506 250 330 200 871 455 668 573 503 214 586 471 263 683 821 176 483 201 379 285 249 248 993 209 691 159 334 251 656 291 379 325 911 598 165 751 137 734 182 129 31 663 652 523 462 46 269 561 573 670 908 407 829 370 280 622 972 191 55 605 859 144 732 221 727 311 770 892 766 984 560 591 650 998 288 873 545 460 859 909 788 667 536 53 178 973 114 943 443 649 987 95 835 64 697 270 219 994 350 271 465 345 233 262 570 621 309 103 838 481 447 107 703 932 28 152 22 337 624 699 34 94 288 697 703 937 921 138 567 839 971 840 805 400 265 569 63 644 635 626 394 284 632 932 750 722 658 907 729 893 120 69 771 936 942 973 634 510 984 29 335 501 266 730 559 8 100 713 61 899 588 393 393 120 717 570 79 548 4 428 526 943 918 286 65 992 825 95 30 141 300 814 899 993 141 545 30 943 302 380 737 46 847 632 58…
Output: 757748

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.