CT53681

Wren Counts the panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the opal reefs of Shimmerdeep, someone must track the breeding season. This year the task falls to Wren, armed only with the panels 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 <= 1396; 0 <= a[i] <= 1000.

Example 1:

Input: 166 48 34 656 80 675 342 38 493 602 796 285 347 891 63 159 773 239 920 73 669 279 733 31 743 602 246 324 849 828 682 794 453 653 654 880 583 776 731 351 291 384 208 317 68 287 296 817 400 618 450 444 575 650 346 555 707 121 999 315 129 207 693 29 980 408 22 481 954 3 750 291 429 682 107 311 674 594 330 456 605 683 768 414 290 626 831 697 938 52 589 4 881 365 181 963 527 813 331 556 220 412 864 487 247 441 796 628 981 166 790 447 787 541 304 245 48 317 624 959 645 50 453 641 391 419 616 569 540 463 269 281 590 486 297 886 887 966 5 866 375 231 263 240 8 358 123 566 535 556 712 646 246 220 649 587 338 432 528 820 148 113 903 732 771 562 932 490
Output: 25287

Example 2:

Input: 1327 1271 488 698 980 289 863 165 324 91 306 924 832 425 417 318 5 496 551 11 397 984 332 964 366 248 955 227 294 699 986 601 0 143 269 657 735 649 68 777 904 772 266 210 176 801 133 720 710 826 511 603 650 803 325 835 224 727 388 588 265 494 971 21 274 565 490 100 210 844 744 242 29 361 67 830 652 562 448 519 92 185 261 952 679 145 9 205 92 572 690 809 515 944 609 189 299 162 527 541 605 558 885 80 206 50 794 476 261 103 919 700 337 110 307 90 42 890 390 668 895 596 450 290 403 815 940 364 246 865 228 377 343 732 750 517 230 468 213 223 606 196 401 810 768 988 512 792 87 465 735 569 919 703 475 279 744 642 836 144 651 480 346 192 982 168 374 20 754 600 308 965 627 5 588 127 117 540 687 211 906 368 961 822 740 226 499 205 807 794 189 892 884 48 678 344 414 995 862 941 894 904 600 427 679 6…
Output: 650861

Example 3:

Input: 408 382 551 281 5 65 308 28 13 872 476 126 561 380 179 729 712 960 287 646 232 609 119 906 91 616 195 445 267 14 446 466 656 575 681 533 286 772 996 788 511 903 51 558 484 54 408 349 630 846 937 61 251 383 403 738 754 28 874 130 707 443 955 420 54 162 111 982 38 140 343 266 295 952 779 74 1000 27 727 211 506 745 801 196 217 114 669 51 42 891 302 664 101 817 716 374 962 565 51 684 905 162 756 898 78 140 525 670 199 672 457 378 499 86 499 102 790 583 271 390 864 299 990 548 230 572 552 549 179 765 188 666 426 112 775 852 481 788 186 501 276 257 606 506 716 27 745 716 733 51 598 293 621 808 458 434 183 410 548 183 785 661 232 970 559 470 441 276 243 674 896 163 386 323 507 964 344 790 234 121 348 833 135 688 744 653 236 213 922 715 515 157 289 558 565 559 240 964 392 386 655 233 885 577 127 9…
Output: 190005

Constraints:

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

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