CT54934

Diya and the Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the copper works of Verdigris, Diya the archivist keeps careful count of the windows. Prove the quality of the harvest, every figure matters. 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 <= 1435; 1 <= a[i] <= 1000.

Example 1:

Input: 1316 1137 114 301 214 727 219 741 764 512 707 520 110 84 769 793 848 879 918 682 148 165 277 183 736 783 548 294 563 551 727 498 666 899 945 87 222 140 966 381 950 331 414 552 717 501 350 316 117 688 358 363 903 817 123 168 351 386 351 618 881 697 833 309 841 525 64 57 425 392 131 114 461 620 192 889 307 111 288 373 681 216 326 459 212 313 681 361 423 546 892 387 393 386 943 119 426 544 382 367 688 152 541 914 539 3 146 334 160 501 194 966 158 16 87 808 857 608 576 383 937 695 328 563 983 568 729 58 541 380 583 638 658 458 961 998 378 307 823 222 891 219 690 7 651 299 549 3 89 495 376 964 787 977 192 556 298 325 439 511 111 52 926 988 421 230 50 11 180 678 273 623 355 513 302 488 171 702 28 21 861 256 883 376 639 518 717 93 493 89 839 706 60 865 805 849 269 667 674 163 299 490 509 374 872 …
Output: 569827

Example 2:

Input: 57 29 651 956 871 700 255 709 970 331 941 158 60 432 791 179 108 913 139 702 20 455 364 245 305 712 610 133 687 918 209 463 414 936 131 373 478 37 121 412 379 1000 681 366 147 142 825 799 776 66 902 268 487 219 543 284 567 519 368
Output: 14524

Example 3:

Input: 1049 106 945 737 661 309 850 552 797 748 277 893 789 658 323 826 325 179 143 676 793 42 305 309 405 822 876 606 270 891 867 791 105 299 954 344 542 758 930 142 824 878 181 906 869 657 400 147 39 154 122 121 383 371 378 355 125 213 453 335 374 857 653 858 580 409 528 678 572 860 134 702 339 371 521 609 480 560 514 489 2 899 733 848 402 787 631 770 482 947 1 354 234 360 781 94 426 214 764 926 494 467 759 451 863 699 980 316 269 371 45 258 785 567 589 236 504 355 90 389 535 597 526 21 191 531 18 313 989 261 292 154 258 379 2 745 403 638 376 351 208 879 754 523 93 251 1000 453 322 870 605 455 949 263 842 126 22 255 462 734 347 410 136 446 114 816 979 253 27 608 996 368 7 921 328 780 538 438 844 986 862 650 674 7 130 943 968 876 46 522 86 772 802 143 825 962 664 444 28 832 627 902 902 348 720 3…
Output: 61953

Constraints:

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

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