CT32426

Peddler's Jade stretches

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the ink district of Scriptoria, someone must compute the guild dues owed. This year the task falls to Peddler, armed only with the stretches register. 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 <= 1536; 0 <= a[i] <= 1000.

Example 1:

Input: 255 200 879 677 495 926 299 478 332 146 180 719 17 397 876 870 109 610 429 726 382 911 802 163 676 444 634 446 170 370 724 981 558 262 144 217 184 627 626 449 922 70 402 314 157 520 758 692 665 111 754 8 451 831 297 447 468 792 426 231 723 113 77 993 7 505 20 830 876 990 401 256 328 443 505 72 203 410 799 897 292 895 517 653 186 896 265 68 654 320 704 67 947 267 540 968 603 235 163 421 590 984 102 825 225 441 947 160 732 190 429 934 799 538 818 299 746 139 299 598 731 207 475 305 736 76 8 711 509 164 608 320 928 96 563 398 880 12 602 439 238 504 369 635 949 115 942 419 917 781 175 988 654 746 109 348 280 830 358 779 514 913 773 976 386 369 445 259 545 358 427 244 710 169 956 628 494 969 635 344 987 476 196 668 777 332 535 304 855 118 358 278 540 825 469 692 593 22 382 265 305 809 509 926 6…
Output: 101666

Example 2:

Input: 1252 1248 65 357 972 859 344 637 781 10 170 285 48 973 43 994 324 89 769 356 895 845 165 211 821 786 383 384 63 942 435 960 636 669 512 794 966 498 801 281 91 6 233 236 496 386 12 471 199 570 35 216 331 399 304 412 787 646 90 24 939 69 556 930 605 75 706 844 444 681 630 751 351 874 466 720 377 473 879 165 339 743 934 553 438 848 165 674 763 509 596 377 364 612 769 961 728 284 182 81 743 783 534 262 83 373 617 661 413 120 673 281 474 508 308 523 686 145 878 410 975 780 410 414 476 652 524 102 255 607 485 755 513 226 993 392 671 266 136 39 83 261 784 809 715 246 620 102 59 672 670 446 109 1 81 469 344 566 868 569 440 798 111 490 810 815 870 193 631 897 424 130 590 588 112 834 86 447 982 742 474 384 414 534 912 943 487 66 3 182 186 512 492 989 419 580 932 920 714 285 820 374 9 502 1000 532 33…
Output: 631699

Example 3:

Input: 17 15 916 271 973 679 715 317 923 42 689 177 973 163 14 588 203 22 805
Output: 7643

Constraints:

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

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