CT43201

Last panels of Smith

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the caldera rim of Firewatch. Smith spreads the panels 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 <= 1534; 1 <= a[i] <= 1000.

Example 1:

Input: 1005 111 361 729 941 302 52 128 47 2 371 194 57 741 636 43 93 334 424 25 636 915 659 327 651 987 559 147 96 554 433 873 323 782 284 672 410 62 572 282 672 594 973 675 532 405 317 412 120 154 504 553 387 85 315 422 592 564 992 207 86 969 252 809 540 148 765 678 857 973 461 40 496 187 989 621 434 859 789 568 865 920 952 810 642 135 301 493 617 853 949 491 391 940 405 908 724 79 472 482 323 820 160 593 764 885 57 427 470 547 144 698 961 991 7 778 1 84 860 416 486 55 190 344 370 170 193 951 827 493 51 357 493 197 735 497 849 242 337 486 919 523 843 224 977 753 313 546 313 529 26 173 177 955 518 753 507 76 25 995 391 737 494 410 929 504 728 495 69 949 159 905 114 955 971 987 49 786 502 446 752 720 85 832 51 587 350 368 445 281 589 917 704 304 499 472 554 801 195 469 579 477 537 856 585 578 211 …
Output: 60206

Example 2:

Input: 128 82 120 230 932 219 375 767 159 530 413 469 864 965 334 382 196 498 930 695 613 797 628 373 471 469 232 420 705 653 402 349 833 33 935 521 800 601 925 565 214 594 292 837 365 345 980 400 59 128 677 669 719 987 460 673 227 726 779 726 186 946 707 715 620 648 297 63 939 58 597 193 152 160 428 970 756 18 112 857 69 397 172 388 411 613 440 757 131 228 909 110 853 564 490 558 958 907 593 323 269 864 196 795 437 782 476 835 780 574 75 46 591 440 318 700 656 214 555 433 86 317 970 441 302 686 879 596 283 846
Output: 43480

Example 3:

Input: 499 120 593 725 187 162 32 646 52 315 698 652 344 542 395 455 188 1 875 334 26 140 539 689 487 104 639 584 639 530 57 561 362 626 848 337 720 522 451 774 888 841 270 671 932 57 751 365 765 528 88 604 960 96 132 697 313 610 716 942 765 669 192 540 458 652 36 802 316 594 251 399 804 919 481 725 390 875 419 800 921 372 992 209 211 117 242 614 199 450 428 647 554 475 156 81 371 31 152 917 568 979 957 284 737 412 962 312 464 849 481 877 422 298 775 336 40 400 838 772 296 589 76 820 316 776 917 224 151 116 245 730 795 449 556 745 593 810 928 141 924 180 188 434 909 378 364 425 812 355 361 519 680 288 338 972 309 774 23 510 909 422 621 323 902 3 599 793 495 660 302 860 1000 547 997 61 894 638 562 211 465 816 655 714 486 705 160 63 424 728 47 4 789 735 436 663 766 539 934 118 5 854 282 687 622 113…
Output: 67078

Constraints:

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

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