CT45029

The Fixed Window Peak at Sandspire

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the desert outpost of Sandspire. Gino spreads the stretches records across the table and picks up a sharp pencil. 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 <= 3798; 1 <= a[i] <= 1000.

Example 1:

Input: 1898 1531 5 122 398 993 32 557 915 708 279 634 103 512 500 860 417 419 213 375 350 125 191 707 482 155 633 525 641 818 418 814 107 945 507 229 520 117 220 970 747 387 651 863 378 309 817 61 88 143 937 487 125 333 167 294 787 266 232 741 661 29 991 577 326 177 407 992 310 311 9 296 280 374 350 243 96 737 515 75 313 462 443 953 81 823 417 628 705 20 137 459 681 712 143 135 815 102 648 471 126 228 737 956 940 361 922 443 704 978 535 194 926 201 913 67 254 998 612 489 726 217 849 230 1 664 121 700 182 198 615 283 305 578 339 687 812 142 959 19 641 257 808 947 434 202 366 230 85 474 618 46 946 987 708 133 104 624 511 546 67 766 977 386 595 970 594 375 370 169 363 193 661 909 925 75 396 301 126 507 95 880 931 173 630 459 989 109 468 543 707 806 190 872 165 179 233 298 74 314 322 637 277 457 703 …
Output: 752401

Example 2:

Input: 3715 1357 426 645 452 199 517 579 785 506 872 184 753 483 525 784 615 557 938 686 484 292 294 777 888 151 627 555 11 396 599 543 61 364 120 610 800 849 899 796 930 189 916 327 672 169 568 458 138 982 230 661 701 351 144 522 929 998 503 836 485 673 696 419 449 691 429 786 319 614 646 826 304 275 460 821 973 763 168 714 189 553 496 454 483 47 360 9 46 224 810 664 152 379 231 519 437 122 326 428 403 341 17 281 786 890 544 416 766 117 329 464 757 637 216 95 349 177 316 69 579 567 458 991 310 635 417 217 847 548 695 322 89 338 370 768 543 300 451 520 996 16 668 563 103 593 685 577 169 817 798 989 84 445 732 507 996 900 685 355 313 167 837 287 190 971 824 836 557 930 503 837 139 806 392 780 473 155 74 675 436 975 913 726 299 232 253 671 342 643 123 519 711 796 391 720 946 744 234 384 399 507 636…
Output: 699115

Example 3:

Input: 3492 91 394 289 363 332 24 792 345 588 346 416 477 766 37 293 137 536 770 76 19 315 897 779 803 359 375 597 418 91 263 399 736 475 186 876 572 863 800 433 266 891 870 141 850 198 4 752 579 68 21 76 481 175 524 62 770 845 77 740 853 869 227 161 708 506 531 732 88 613 919 463 472 335 321 379 783 332 828 41 65 352 505 540 742 231 887 35 320 681 822 817 969 774 925 778 318 446 501 583 809 157 339 264 120 299 305 43 877 368 560 478 417 44 375 686 670 863 257 615 370 162 958 557 449 844 162 611 929 368 391 518 261 676 892 993 671 434 952 665 425 479 636 29 200 904 881 905 858 85 366 987 156 259 905 113 468 688 416 691 970 467 201 161 769 139 697 887 462 709 624 876 161 658 578 85 326 245 619 689 653 774 734 150 471 991 715 55 715 329 827 20 394 894 380 989 947 979 829 883 185 207 964 196 211 86 …
Output: 54432

Constraints:

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

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