CT53730

The Sleekwater Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Wasim inherited the depot at the otter slides of Sleekwater along with its curious bookkeeping system for segments. Time to make sense of it. 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 <= 3037; 1 <= a[i] <= 1000.

Example 1:

Input: 243 43 976 319 246 638 81 663 13 855 224 875 537 794 544 73 740 108 828 607 115 826 698 392 263 215 14 588 780 523 759 818 474 560 280 953 580 858 370 567 551 337 768 635 838 902 706 251 722 50 68 93 841 679 129 937 268 624 96 836 764 150 800 776 457 11 758 453 343 206 648 614 624 652 601 831 327 57 946 939 552 711 46 256 937 281 994 939 28 677 572 263 606 599 717 306 679 471 407 8 841 283 327 907 494 775 922 834 711 72 688 873 306 637 637 400 869 129 5 736 977 211 439 760 106 372 6 649 270 151 540 394 112 305 128 846 746 553 24 792 519 917 906 349 720 473 115 950 442 690 722 183 530 527 600 794 23 632 167 860 766 275 536 740 193 113 793 36 627 910 498 397 340 29 497 525 594 966 155 825 692 232 499 87 989 463 835 882 914 376 173 256 205 734 22 959 403 820 300 481 252 941 945 126 354 607 24…
Output: 24357

Example 2:

Input: 1976 1767 512 274 306 186 698 990 40 12 183 449 799 498 333 380 732 500 389 149 555 290 443 738 953 354 423 199 1000 118 361 175 651 593 855 120 683 948 58 410 715 591 271 765 610 233 991 934 178 169 102 747 328 696 397 445 451 659 201 158 288 192 652 44 477 553 929 10 761 979 396 401 750 419 776 542 558 322 587 96 427 500 66 489 824 731 795 628 798 710 728 836 301 422 401 651 753 644 238 427 690 205 495 251 825 1000 871 523 211 986 30 842 109 390 127 631 359 279 763 231 813 161 658 725 396 717 226 866 225 139 515 975 67 644 82 219 97 550 438 195 881 997 632 11 875 167 471 263 163 629 942 356 363 255 212 267 820 682 176 86 314 682 220 562 69 242 56 248 40 443 997 649 657 140 992 623 31 402 64 303 694 880 115 479 153 368 590 348 553 764 56 877 358 1 312 301 440 99 507 257 400 758 992 880 15…
Output: 897740

Example 3:

Input: 2151 1677 659 908 799 156 126 581 950 734 156 249 639 999 47 188 420 14 777 796 972 550 307 117 935 688 979 764 144 6 168 835 876 587 577 148 363 334 982 789 43 71 619 576 592 706 494 83 66 137 316 905 801 957 509 209 185 950 368 132 205 996 192 96 551 200 771 445 917 119 487 905 88 642 428 199 286 168 407 942 72 95 317 60 55 488 691 847 473 472 627 226 790 553 381 613 844 565 76 721 916 637 257 358 900 231 533 105 59 377 264 768 656 728 315 924 315 652 23 307 974 716 860 106 63 358 272 113 994 478 639 769 769 789 466 372 914 43 543 307 603 534 355 987 298 162 451 928 554 14 470 539 64 932 861 112 434 149 294 312 870 682 142 726 968 984 901 758 852 810 83 70 934 430 897 912 868 393 322 766 175 542 254 916 770 468 203 418 496 435 459 903 298 62 674 422 49 704 589 972 986 132 386 614 635 906…
Output: 840156

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Sleekwater Fixed Window Peak - MEDIUM Coding Problem | CodeTikki