CT38618

The Jade Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Elio runs the apothecary at the lily shoals of Padmore. Today the books show a list of scrolls, and the numbers must be worked out before sundown. 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 <= 2012; 0 <= a[i] <= 1000.

Example 1:

Input: 175 86 564 425 71 957 190 555 587 967 938 329 916 979 588 430 580 517 42 777 782 723 928 14 29 525 926 66 239 288 486 691 269 199 758 969 849 303 633 534 754 665 362 606 653 447 939 669 786 705 484 769 565 158 640 55 397 438 849 803 729 26 752 467 474 790 97 457 600 549 355 271 208 158 607 90 780 851 462 355 963 780 817 294 625 809 268 354 286 174 7 848 458 39 807 453 360 964 666 563 811 196 140 164 539 532 36 90 824 210 249 669 839 113 686 326 962 366 132 690 691 925 454 547 199 995 581 181 817 837 262 690 439 425 819 460 417 882 872 958 949 704 538 952 648 777 275 176 337 162 471 284 754 908 204 418 876 703 302 214 255 579 413 191 4 704 227 556 386 463 573 631 325 533 988 801 888
Output: 46355

Example 2:

Input: 915 710 658 564 369 368 820 860 847 941 752 539 211 481 1 875 30 666 374 658 690 664 217 156 491 551 853 816 771 840 840 626 390 111 33 271 550 120 705 727 795 881 793 803 653 172 668 172 761 706 0 347 254 527 73 573 59 1000 782 709 711 532 915 91 710 489 663 566 825 22 960 451 473 732 740 189 703 493 581 166 300 164 687 438 525 237 206 636 899 176 328 242 84 835 958 819 662 811 416 471 568 424 978 275 981 54 583 388 712 600 346 68 746 567 371 188 224 100 99 891 299 772 412 704 944 43 397 986 163 770 301 896 408 999 228 387 211 115 157 234 77 422 65 101 715 805 500 807 704 924 357 797 259 350 712 248 678 453 737 168 269 792 985 564 817 637 304 280 654 648 601 604 867 378 892 791 573 524 895 886 253 978 175 332 632 432 720 754 284 170 688 862 205 532 174 527 913 354 576 451 769 972 641 538 …
Output: 380618

Example 3:

Input: 921 421 893 845 403 35 313 21 715 856 745 829 811 337 776 13 732 620 37 35 374 536 255 267 748 886 306 142 386 784 220 770 341 329 107 186 846 297 880 993 320 603 393 737 131 355 702 25 794 731 778 599 794 508 318 886 734 419 397 199 250 923 94 997 411 193 165 566 339 936 564 918 234 324 564 819 702 953 450 449 392 810 896 72 369 849 629 402 977 4 754 399 172 874 645 389 823 341 961 7 70 170 779 685 130 126 486 772 163 265 247 96 715 368 557 228 158 173 669 634 513 457 40 717 989 762 863 466 468 711 14 792 421 258 666 970 912 761 332 737 927 172 343 650 964 667 567 75 942 875 352 302 848 878 264 421 476 341 38 201 615 605 82 290 939 124 458 119 371 367 396 277 199 864 345 158 488 965 411 273 783 500 649 660 450 839 735 254 32 567 288 850 284 338 859 976 398 876 477 369 928 602 950 257 557 …
Output: 210148

Constraints:

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

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