CT48853

Theo and the Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the monsoon port of Rainhaven, someone must decode the foreman's shorthand notes. This year the task falls to Theo, armed only with the windows 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 <= 3662; 1 <= a[i] <= 1000.

Example 1:

Input: 2579 200 62 102 299 413 715 271 52 720 716 276 228 654 684 27 233 866 65 11 86 912 545 360 737 799 662 218 364 85 600 888 102 136 461 491 940 98 864 657 658 984 655 894 425 82 63 1000 794 606 399 909 797 836 593 983 72 740 228 230 784 555 730 799 47 113 312 956 283 612 524 128 624 818 413 912 917 934 864 287 874 802 514 533 116 172 445 362 323 61 788 99 991 525 167 891 292 180 489 618 55 873 282 630 201 35 422 926 275 506 5 631 748 221 48 215 322 139 708 726 448 590 5 939 444 806 21 359 283 670 193 165 74 503 40 863 743 558 21 876 194 158 328 775 721 166 159 773 1000 23 736 732 913 670 262 173 861 836 568 977 556 4 980 107 906 942 926 41 237 595 544 982 915 990 479 547 358 7 240 365 329 986 605 193 647 85 960 479 887 382 835 747 534 941 524 505 589 75 18 145 527 688 931 618 477 625 76 756 …
Output: 109410

Example 2:

Input: 816 217 58 66 449 945 490 380 413 854 134 584 882 166 803 276 626 401 333 752 712 458 12 982 922 522 864 537 739 147 92 705 42 893 322 873 943 700 492 913 154 540 847 787 617 886 780 810 81 652 53 548 954 782 906 217 7 642 191 48 666 966 562 777 728 814 492 176 883 937 141 277 792 79 425 86 704 496 442 577 804 807 127 503 752 580 535 901 929 505 344 289 270 296 862 994 314 919 948 378 989 157 914 794 46 778 368 649 244 441 163 384 295 536 579 285 9 817 56 97 215 792 965 783 614 830 562 489 747 110 39 358 201 356 418 613 587 613 238 146 688 719 804 363 206 820 203 411 224 567 46 999 134 732 508 917 244 448 500 431 36 33 26 871 456 366 911 749 519 832 733 4 454 426 141 988 803 104 908 667 332 654 961 411 202 515 40 457 95 578 373 35 762 346 570 314 61 380 831 380 719 746 146 221 704 230 107 …
Output: 126271

Example 3:

Input: 1358 342 510 737 969 615 494 649 817 902 377 246 588 195 132 163 58 976 740 635 562 498 996 929 538 274 792 666 69 452 374 685 736 993 186 337 41 519 968 243 314 619 809 535 839 611 589 579 316 513 662 72 968 950 45 730 303 233 693 845 302 331 681 680 809 954 129 963 768 120 392 563 868 836 593 115 687 184 707 40 992 536 281 390 870 207 128 146 4 450 895 994 586 72 439 118 256 665 962 321 578 400 548 299 516 686 119 638 543 589 242 277 561 806 633 556 584 883 32 877 551 688 387 157 268 646 920 419 777 133 625 218 978 625 685 447 771 238 357 352 904 121 958 241 612 81 306 129 141 44 258 41 478 619 611 476 596 918 872 191 73 73 730 873 280 888 384 301 155 252 572 147 565 397 330 488 514 287 519 367 436 6 474 228 813 933 701 47 525 497 410 270 220 877 574 244 266 780 744 874 394 438 918 681 9…
Output: 175231

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Theo and the Fixed Window Peak - MEDIUM Coding Problem | CodeTikki