CT35756

Mira's Fixed Window Peak Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The auditor Mira has been asked to rank apprentices for the new term. On the desk lies a long table of scrolls readings. 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 <= 1853; 1 <= a[i] <= 1000.

Example 1:

Input: 45 22 716 877 332 10 694 799 973 860 212 530 936 848 557 598 44 682 866 80 824 654 833 896 170 339 272 415 120 875 908 826 185 540 663 396 950 721 245 61 728 996 656 511 728 48 348
Output: 13821

Example 2:

Input: 361 37 668 289 878 566 97 263 719 880 437 772 882 454 865 426 548 347 12 934 785 626 452 702 419 529 883 133 895 109 259 860 816 712 139 225 797 140 963 692 505 904 503 670 790 314 531 480 130 223 304 155 980 645 261 93 419 431 605 562 806 521 636 600 715 889 974 690 179 137 903 378 976 558 433 943 294 80 524 469 99 2 590 753 235 928 293 313 563 844 234 685 557 745 901 450 540 536 519 367 847 662 911 300 740 265 433 631 79 563 23 773 722 958 51 25 683 234 353 14 561 335 324 468 781 735 939 275 170 20 306 673 355 382 457 690 859 270 101 893 472 617 577 257 205 337 534 43 498 864 747 377 937 59 147 613 368 988 922 768 914 252 683 286 438 645 985 668 968 977 658 751 958 97 133 673 1 816 188 77 393 877 882 683 67 298 906 112 651 307 638 821 423 483 64 285 877 633 206 751 799 43 928 556 830 344…
Output: 21784

Example 3:

Input: 888 657 536 718 960 255 621 313 843 481 369 1000 664 36 426 264 387 923 800 77 509 601 70 455 471 910 199 431 883 278 247 323 566 28 641 408 19 226 303 692 405 448 271 683 404 834 990 473 500 782 84 415 675 542 24 770 106 512 148 746 706 829 701 415 474 553 665 424 621 845 66 720 157 134 388 612 641 385 215 254 504 314 347 496 305 235 173 820 693 896 613 379 940 446 461 64 328 578 88 29 229 122 561 457 109 466 592 570 814 313 653 492 846 459 867 669 498 102 994 60 655 454 185 173 167 642 822 681 714 107 529 332 449 720 205 432 600 263 784 32 94 825 927 551 191 842 11 389 435 91 987 211 519 93 752 875 418 800 865 269 856 183 999 181 493 498 834 651 180 379 964 634 460 898 930 5 186 228 805 726 213 812 651 342 363 681 127 726 655 598 511 479 406 660 719 991 712 900 423 566 741 859 778 644 61…
Output: 326332

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Mira's Fixed Window Peak Ledger - MEDIUM Coding Problem | CodeTikki