CT46535

The Sterling segments of Brewer

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The assayer Brewer has been asked to settle a dispute between crews. On the desk lies a long table of segments readings. 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 <= 1202; 0 <= a[i] <= 1000.

Example 1:

Input: 669 639 738 923 266 710 493 68 346 11 45 74 16 719 813 148 329 767 830 888 184 675 949 40 38 918 251 446 173 314 198 272 595 458 881 129 443 363 311 182 954 698 45 110 396 185 259 339 980 937 746 277 761 26 535 533 959 320 297 64 167 566 38 547 309 42 147 268 76 55 254 231 637 746 819 25 69 343 48 633 736 567 667 598 510 151 551 793 375 389 768 31 726 940 721 465 95 120 628 792 878 886 383 593 202 830 491 692 24 260 687 348 427 224 615 392 237 796 372 884 441 29 309 187 411 143 733 154 152 875 797 492 417 18 607 456 492 236 191 26 555 209 359 841 347 118 453 567 579 683 387 781 251 579 522 325 106 205 479 695 761 207 241 433 888 293 579 96 457 964 718 311 192 161 560 184 835 700 576 896 263 622 827 764 848 322 345 136 466 32 180 161 545 724 522 648 919 692 969 514 740 873 714 257 411 594 5…
Output: 317340

Example 2:

Input: 153 102 314 724 893 833 735 342 408 155 837 134 656 570 630 798 208 562 448 492 224 181 701 206 379 685 227 678 104 921 382 42 904 83 659 255 809 913 987 783 655 203 23 961 528 558 108 286 843 312 227 6 823 221 174 41 434 464 834 204 285 525 629 415 900 173 908 678 964 429 125 218 256 133 601 699 811 472 632 169 540 391 341 162 202 301 145 834 208 833 392 704 806 377 541 13 410 959 43 234 407 951 938 970 288 761 990 882 167 94 252 254 350 9 127 817 235 205 17 310 540 872 397 677 90 751 475 543 665 209 402 278 306 491 337 290 669 404 165 450 112 452 924 442 894 246 815 377 921 732 705 983 927 92 586
Output: 49648

Example 3:

Input: 789 736 825 518 103 178 414 163 229 671 140 206 961 135 853 76 239 64 266 954 634 804 581 172 536 469 276 977 794 708 942 488 17 557 414 719 780 999 716 664 170 78 111 743 181 642 470 111 925 270 869 470 109 527 136 611 489 780 302 13 984 339 810 540 36 368 297 229 452 703 996 93 813 60 652 607 812 766 328 181 282 626 115 640 936 720 910 600 219 225 232 515 946 308 63 33 164 971 49 561 665 355 890 343 561 706 502 198 527 104 909 531 859 636 727 469 152 947 726 499 356 640 19 866 151 563 501 26 533 808 472 518 413 911 872 217 165 871 864 675 119 835 447 385 412 453 896 792 392 754 519 615 353 174 157 33 259 477 737 312 13 547 893 250 283 553 688 718 488 185 581 152 962 919 738 176 583 965 865 639 721 671 82 783 909 847 764 289 960 340 296 633 339 504 417 9 363 227 943 373 413 622 262 582 69…
Output: 361221

Constraints:

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

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