CT46996

Lakshya's Fixed Window Peak Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the spice bazaar of Saffronia, Lakshya records each segments in a worn leather ledger. The guild wants answers, not guesses. 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 <= 3638; 0 <= a[i] <= 1000.

Example 1:

Input: 3392 1466 558 955 630 824 682 77 170 376 691 50 946 877 219 170 185 609 264 952 669 279 121 686 657 225 721 480 447 364 924 175 749 768 814 219 25 880 41 500 946 203 795 118 509 906 848 91 1 11 117 567 839 880 416 193 797 844 268 454 145 676 618 394 384 676 527 350 291 145 678 711 1000 817 302 450 665 377 185 353 240 370 312 934 798 242 159 262 581 631 444 816 644 496 158 623 162 488 705 826 403 975 813 824 242 39 594 454 697 465 166 617 883 924 123 291 345 446 566 154 246 294 785 206 804 249 962 294 479 522 644 466 735 506 622 318 258 627 952 897 719 214 12 1000 516 22 652 554 217 53 863 543 756 231 575 14 387 635 991 212 454 563 679 41 832 572 983 346 88 698 797 548 704 311 583 84 304 175 872 474 379 867 877 963 53 286 953 684 833 703 103 35 872 103 243 955 366 644 284 314 256 122 866 81…
Output: 746051

Example 2:

Input: 823 815 646 387 59 491 605 736 88 113 592 462 627 416 677 777 121 827 300 412 605 484 36 758 667 975 962 56 874 715 216 414 95 404 664 202 366 576 563 14 163 235 519 812 541 556 645 974 537 396 169 571 25 334 23 817 654 877 187 884 201 704 267 584 719 869 231 720 540 738 0 492 275 273 160 997 152 129 975 646 570 359 420 641 976 902 201 348 163 733 629 32 613 832 434 153 535 364 854 424 334 738 877 68 144 524 629 423 721 535 38 479 964 113 632 727 241 69 374 212 197 297 174 520 376 166 128 547 462 819 158 66 279 480 999 911 723 592 604 147 512 995 456 194 397 535 630 593 970 63 145 392 379 984 528 796 54 837 500 747 4 459 145 710 886 412 765 233 198 230 467 277 906 969 911 882 726 920 327 654 183 634 601 688 718 365 544 116 450 286 342 136 687 938 928 440 941 562 830 42 256 692 51 636 471 6…
Output: 419605

Example 3:

Input: 1231 509 170 440 557 329 699 297 991 438 365 465 952 671 978 548 962 590 933 936 752 622 58 508 370 507 246 320 596 766 168 553 188 567 803 292 493 650 763 281 627 461 487 750 946 444 756 853 747 98 349 832 75 896 739 706 180 189 523 120 718 10 389 169 293 766 303 613 121 890 779 22 925 728 842 234 622 583 805 615 83 265 35 246 419 660 165 928 890 977 326 615 500 951 137 141 684 559 536 137 615 50 451 136 172 776 735 693 483 919 313 353 380 804 29 567 62 92 130 918 150 578 189 941 548 321 172 707 201 59 882 634 218 558 695 561 31 515 761 206 992 790 649 573 822 244 886 899 662 446 787 675 844 298 907 880 845 105 828 910 802 209 39 714 78 792 813 828 963 96 973 696 311 423 560 504 284 545 577 73 102 847 435 637 110 614 285 619 648 693 375 271 901 784 72 786 613 274 763 552 825 602 910 149 5…
Output: 274169

Constraints:

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

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