CT45964

Tanya's windows Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Tanya the tallyman watches over the shipyard of Keelwind's stores of windows. A careful computation stands between order and chaos. 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 <= 3002; 1 <= a[i] <= 1000.

Example 1:

Input: 1646 314 5 153 224 890 506 212 923 481 534 562 63 547 658 332 999 946 191 91 344 275 493 532 260 786 87 918 517 591 332 668 329 207 902 108 883 900 108 8 184 828 956 810 23 549 921 339 835 59 680 569 479 993 462 953 423 27 663 895 391 423 296 949 97 342 965 117 433 844 627 616 139 883 900 721 931 683 276 710 263 860 590 623 689 90 544 201 711 146 611 8 326 87 686 976 773 395 113 424 17 57 5 898 857 797 627 777 904 268 643 573 885 617 686 117 883 918 477 491 875 80 859 159 693 318 62 206 728 382 555 989 320 709 83 209 202 652 796 694 340 550 772 187 36 838 581 701 481 353 449 662 521 488 491 712 134 480 101 738 648 356 860 442 880 856 936 607 41 342 503 308 704 34 858 206 583 505 114 271 777 362 194 143 326 906 904 343 270 474 121 151 28 513 419 410 257 367 845 38 801 632 492 688 558 123 73…
Output: 162154

Example 2:

Input: 758 692 519 301 227 940 631 284 46 591 922 311 872 404 287 202 287 720 842 240 454 206 467 501 502 231 665 356 915 55 748 133 885 588 721 300 826 102 65 632 208 974 797 278 912 999 790 516 845 26 430 597 928 471 873 210 759 508 341 973 987 337 992 731 796 275 418 760 365 585 344 178 3 110 336 582 962 855 405 495 325 713 301 623 471 792 106 159 544 550 174 940 704 764 503 461 226 982 443 48 937 59 307 457 595 467 996 420 358 467 367 343 420 945 727 239 910 882 924 947 580 243 472 405 493 613 9 626 437 275 133 83 290 65 543 885 247 778 634 977 836 364 474 454 256 169 318 353 653 776 332 713 941 959 845 344 459 748 931 182 370 721 456 793 729 892 572 502 146 207 979 681 233 787 770 94 541 332 171 789 750 269 686 458 945 944 30 577 342 645 296 980 771 378 147 429 159 107 66 241 643 338 259 101…
Output: 355980

Example 3:

Input: 636 388 324 65 441 953 764 484 184 897 410 999 407 874 385 515 378 335 192 825 46 135 564 118 442 424 345 999 903 747 563 857 998 364 217 305 384 41 322 232 200 132 158 908 918 274 62 796 968 299 544 223 238 606 905 614 326 132 654 308 811 389 133 833 382 590 599 905 725 421 526 767 189 15 891 748 868 917 277 834 671 424 871 699 337 611 451 504 749 82 634 578 359 43 806 744 642 968 530 549 730 366 823 73 964 436 206 761 654 721 16 940 526 91 171 367 83 714 834 457 718 34 488 289 778 180 659 110 285 180 610 276 751 481 216 497 149 425 26 102 897 127 755 446 573 36 430 256 9 614 81 8 483 203 203 357 330 902 479 353 430 396 968 109 734 837 353 838 325 952 736 82 80 333 884 131 616 133 178 913 957 538 270 717 597 730 372 653 392 783 349 272 3 403 706 553 544 902 827 555 608 396 652 936 855 423…
Output: 195585

Constraints:

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

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