CT48517

Yash's Fixed Window Peak Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the orchard lands of Applerun close for winter, Yash must finish the stretches ledger - one figure at a time. 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 <= 3148; 0 <= a[i] <= 1000.

Example 1:

Input: 1531 632 993 120 863 532 270 329 781 635 133 541 569 972 265 109 245 940 812 250 160 755 267 727 277 344 319 254 390 535 493 731 503 688 762 599 72 394 491 27 112 854 727 5 129 851 115 633 57 61 759 711 33 338 181 272 745 733 113 606 958 933 301 768 162 96 942 611 902 664 569 890 808 329 602 532 395 267 723 195 455 45 53 735 812 954 174 916 120 137 551 557 861 108 497 816 907 907 129 97 874 587 171 668 640 196 113 836 391 826 106 767 215 879 974 186 279 484 280 36 102 45 24 497 216 381 72 539 501 394 556 350 71 775 732 353 722 847 413 484 320 477 700 499 444 789 833 319 975 316 673 831 161 846 663 12 440 895 168 804 930 345 273 686 479 827 715 864 872 17 282 998 558 847 538 813 170 189 278 227 68 745 978 318 448 339 850 326 132 853 583 32 291 733 24 572 349 188 312 476 680 157 557 177 214 …
Output: 324186

Example 2:

Input: 2566 2030 753 740 60 643 212 435 29 271 940 615 800 61 941 743 530 835 305 884 424 978 432 200 254 392 98 555 51 957 469 306 276 98 171 445 467 406 330 667 81 445 485 123 502 800 710 775 542 620 427 550 473 186 21 748 149 344 389 383 370 917 246 575 792 870 168 161 397 268 178 331 723 958 410 617 744 551 846 322 305 323 862 490 106 122 724 130 304 238 526 567 997 226 381 110 12 923 122 188 460 230 676 860 641 646 629 765 907 109 654 198 688 803 434 192 39 691 700 831 674 774 767 579 250 308 334 539 617 791 731 114 306 752 565 806 425 773 631 398 960 993 173 863 814 984 858 895 609 370 823 971 247 683 521 298 368 255 350 388 152 48 236 276 121 109 48 773 758 10 737 519 345 430 712 248 865 444 136 483 119 954 34 733 715 850 637 925 501 872 485 770 357 257 318 124 643 474 873 822 856 755 194 …
Output: 1020578

Example 3:

Input: 2986 2613 526 61 53 586 500 619 761 341 516 39 455 83 325 118 143 817 868 748 622 5 689 343 454 783 472 796 445 226 615 9 592 589 831 752 268 800 442 573 984 769 815 65 884 836 872 330 128 797 300 80 640 621 160 367 335 588 993 950 981 648 977 604 461 207 856 607 932 571 583 951 352 28 524 673 535 362 646 380 580 460 596 786 89 270 188 337 943 777 646 281 933 71 78 212 395 971 749 529 878 987 592 705 876 772 514 394 533 126 79 950 765 145 687 692 593 23 894 264 354 489 19 937 130 237 734 884 393 616 73 873 772 506 58 893 409 165 256 85 587 476 620 27 687 895 731 176 184 855 224 735 173 969 566 754 689 731 80 100 490 983 628 495 463 144 716 9 38 168 312 447 774 501 642 22 499 765 653 737 571 67 545 796 266 803 15 827 424 696 982 189 325 16 84 196 837 873 797 456 395 137 4 809 815 648 244 79…
Output: 1333644

Constraints:

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

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