CT46073

The Fixed Window Peak of the Faded windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the wheat plains of Amberfield, someone must price the new merchandise line. This year the task falls to Zaid, armed only with the windows register. 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 <= 3965; 0 <= a[i] <= 1000.

Example 1:

Input: 3068 1588 951 109 55 211 34 591 209 16 618 285 152 876 485 362 118 503 385 73 225 475 911 647 829 0 323 779 154 625 933 308 822 325 537 169 232 360 382 587 434 498 765 434 993 711 190 997 776 748 818 607 97 204 307 238 331 206 741 23 561 9 846 387 753 559 747 503 342 107 99 676 716 667 129 752 211 417 302 364 478 589 693 307 885 461 476 253 344 599 106 640 572 486 113 855 757 768 629 289 777 183 965 708 931 939 753 162 375 369 514 123 742 275 448 275 933 986 58 668 614 728 173 197 332 650 935 83 909 681 481 620 759 729 654 748 816 379 170 95 235 534 877 583 720 330 861 213 939 677 111 516 676 238 245 413 940 332 22 699 344 813 859 235 261 920 964 339 359 62 676 399 689 894 34 833 105 378 397 957 994 326 407 671 625 615 534 87 502 152 828 441 550 806 277 413 585 681 324 484 222 311 673 807 …
Output: 821314

Example 2:

Input: 1757 1121 802 54 588 793 506 859 602 926 743 967 154 853 917 184 52 243 592 566 81 198 39 545 391 6 369 841 97 74 245 576 765 486 72 401 895 641 990 496 467 461 461 320 511 675 306 28 310 1 931 366 324 681 349 323 126 668 731 929 485 89 365 696 695 960 924 0 364 606 694 233 148 308 329 347 798 341 121 731 618 636 435 149 154 622 887 713 32 236 113 7 767 253 429 669 143 423 584 41 259 880 561 194 435 259 625 902 303 688 873 582 807 260 676 558 749 483 282 5 697 319 631 168 144 162 660 342 255 61 689 566 474 417 516 759 965 757 266 207 447 294 497 883 108 543 493 623 667 50 565 99 679 973 599 264 158 742 366 206 446 44 531 723 451 426 40 19 374 31 713 235 613 851 118 428 294 589 693 367 621 417 215 336 8 672 593 698 435 88 985 872 145 84 572 435 335 21 55 194 732 812 594 4 182 259 367 831 15…
Output: 578580

Example 3:

Input: 571 291 703 286 534 198 375 300 845 317 128 899 288 898 906 259 775 494 173 636 604 28 652 173 784 67 209 291 186 483 293 9 864 277 517 883 232 350 269 804 878 947 63 455 995 754 849 725 808 426 174 210 949 14 774 527 875 386 8 768 973 647 378 400 305 38 436 89 593 365 959 362 541 184 447 646 544 492 37 359 454 671 109 1 636 418 509 983 280 199 90 444 549 493 166 423 475 491 659 72 897 405 224 134 974 909 677 613 683 71 28 93 879 587 886 637 799 604 304 874 20 387 147 311 831 761 19 949 353 541 32 351 690 882 667 33 38 1 662 279 866 190 364 683 228 926 805 236 699 253 437 293 251 101 332 958 869 93 345 118 320 358 573 201 786 911 506 538 244 895 715 41 370 530 721 783 84 976 432 674 325 246 668 385 140 488 793 551 232 888 299 51 622 83 822 679 926 685 327 133 2 116 672 946 848 320 532 386 …
Output: 152415

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.