CT44062

Koda Counts the stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the wren hedges of Thimblewick as Koda unrolls the day's manifest of stretches. The tally will decide the next shipment. 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 <= 3591; 0 <= a[i] <= 1000.

Example 1:

Input: 1461 1258 898 816 35 948 818 542 718 604 564 139 397 691 79 709 804 136 266 795 343 276 972 303 457 450 45 969 153 243 525 18 422 653 101 75 884 76 887 533 64 935 529 761 953 580 471 480 690 17 403 585 403 675 606 571 513 868 278 745 860 238 818 618 325 308 527 353 795 96 414 362 360 168 14 478 282 946 305 515 511 505 992 936 986 44 950 544 838 639 626 983 971 62 117 307 148 788 621 814 259 61 407 156 829 657 760 303 736 707 474 542 97 164 439 74 950 893 550 533 111 710 894 113 949 331 293 264 594 380 704 174 883 969 963 616 876 447 918 578 756 14 963 434 732 207 115 513 657 939 282 706 821 288 839 588 588 397 519 341 770 435 126 180 590 92 627 535 401 174 475 29 961 682 921 751 23 826 26 963 166 456 263 880 223 981 841 754 183 938 464 18 876 78 622 422 465 974 716 33 634 317 970 690 797 5…
Output: 621138

Example 2:

Input: 3240 61 263 848 433 81 413 755 263 891 731 804 39 391 221 23 572 346 418 444 355 682 591 839 433 347 90 833 896 71 933 557 482 190 102 70 682 60 327 339 170 951 66 32 54 777 251 933 286 465 733 940 459 174 288 530 59 668 104 0 531 451 931 26 871 309 960 646 266 813 352 548 845 499 48 259 969 563 229 876 14 701 84 320 905 90 304 598 827 962 29 427 226 969 12 265 19 991 715 124 988 714 461 741 978 471 965 133 218 337 125 898 674 379 90 112 564 575 975 346 717 454 930 745 876 637 729 510 667 978 296 820 93 389 204 320 805 424 972 584 115 644 863 219 134 106 222 790 743 433 613 472 406 889 322 151 895 135 295 28 344 105 557 740 231 534 155 276 869 224 273 248 889 843 956 900 386 535 959 756 791 415 532 505 79 593 454 714 577 989 220 780 829 317 78 264 372 45 20 313 507 196 287 533 888 635 253 …
Output: 40237

Example 3:

Input: 2951 148 744 251 416 810 743 364 530 756 77 796 653 697 45 423 945 773 176 758 743 70 669 372 682 389 523 0 250 506 243 624 371 758 19 191 676 503 41 566 277 328 238 890 234 332 790 134 925 715 350 971 253 349 127 730 849 983 163 191 348 821 975 883 337 633 747 499 820 426 26 644 74 2 180 503 242 674 8 561 325 937 102 200 883 789 518 770 803 64 181 232 400 539 158 660 907 687 198 129 743 907 260 240 234 565 132 397 80 336 77 555 55 565 744 176 345 575 6 946 948 53 939 82 250 580 362 334 730 875 477 577 35 401 458 275 452 514 455 25 6 725 186 413 276 598 661 130 490 183 540 847 623 830 505 913 830 898 378 818 244 489 468 290 579 219 73 704 361 74 979 823 543 964 154 244 120 359 987 5 606 596 78 971 386 86 12 742 217 145 259 318 996 835 521 838 501 481 89 63 681 914 944 484 25 579 264 535 55…
Output: 81818

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Koda Counts the stretches - MEDIUM Coding Problem | CodeTikki