CT45489

Nils Counts the panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Nils the chronicler watches over the jade shrine of Serpentis's stores of panels. 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 <= 3604; 0 <= a[i] <= 1000000.

Example 1:

Input: 2831 790 313211 855260 359953 871705 901541 214349 3872 591733 187534 196073 370873 323609 309242 476027 713367 155533 38150 473448 242376 230186 768110 457817 304694 486949 358028 389791 407929 163357 651203 243712 433328 76696 665343 145420 546490 509065 870230 235982 943638 421031 443519 17309 21316 670371 173265 835437 494768 126649 339892 612871 401049 749594 767724 521841 878352 849220 939457 828004 458449 834599 402257 141637 441869 339985 934865 876886 101664 308731 723379 93324 682526 171370 655673 272865 584022 223450 275040 212882 476494 682483 263189 593596 977296 974153 326956 553527 600924 552024 601585 973704 718963 955176 371390 622627 550224 105304 445690 372711 479159 116761 300579 503983 299438 352250 893335 268738 314185 512924 960868 836745 584348 256434 99739 752232 8…
Output: 411708395

Example 2:

Input: 3025 927 424614 75429 829171 678665 77216 74709 16570 793918 206268 826003 420924 186441 489307 805334 55577 729640 77988 865071 304736 858995 80137 529135 769116 872379 395437 641680 910735 135872 677775 100354 159820 650222 80720 172105 313739 521686 449003 184983 548192 952047 719418 592653 798912 967090 78571 42573 613267 780105 498326 961157 967183 59270 615894 235074 709939 625767 333043 488183 901840 464567 486663 775313 901878 481520 977338 348583 83202 215599 990178 85863 626821 248560 580042 954669 870563 461286 280555 334064 213480 10410 61113 487202 586041 123822 442413 747465 2869 366254 863305 20726 587613 185985 983538 499516 259501 547718 41031 782969 459273 492582 246223 286982 936745 929630 799437 308112 646390 909993 196958 718246 892466 514073 656349 767405 919816 32003…
Output: 476459385

Example 3:

Input: 3256 2820 820346 173478 936333 576376 628866 839291 949586 956830 564525 779508 366782 404092 74096 382569 685378 237429 993883 880891 695931 274079 452828 357038 783422 805520 663140 464553 577986 964013 50334 495428 246803 697281 149891 176569 139798 421799 667875 320392 513402 559777 551946 413389 691879 120153 167470 535399 842312 992835 150468 139841 253158 447620 1219 433427 953223 906903 886415 975915 11474 952352 492823 65743 573863 274479 913603 855876 363376 878858 294335 695209 625820 171897 593263 783137 391598 213766 687792 587 704220 545361 847174 382821 705964 538635 285938 174368 823486 723697 583279 638831 925926 677471 98483 47457 554567 34746 730260 8932 595233 53113 322310 650386 82495 372560 108447 332916 557463 104635 258216 528022 111285 802098 605785 211796 235311 8…
Output: 1414505011

Constraints:

1 <= k <= n <= 3604; 0 <= a[i] <= 1000000.

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