CT54912

Freya and the Ember ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the old quarter of Brasshaven, Freya the reckoner keeps careful count of the ribbons. rank apprentices for the new term, every figure matters. 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 <= 3348; 1 <= a[i] <= 1000.

Example 1:

Input: 3051 1619 593 477 34 277 945 954 373 425 817 842 819 573 480 725 740 564 112 297 651 213 690 961 632 837 324 649 320 826 518 83 700 261 959 620 522 296 225 662 514 252 193 486 750 713 573 419 44 552 870 436 92 675 700 698 571 947 982 613 468 310 69 342 653 358 115 849 430 386 361 584 603 503 306 565 874 512 637 624 255 499 409 132 201 883 366 183 985 741 845 429 355 386 690 830 453 911 592 667 820 817 951 353 142 520 44 393 258 730 982 618 907 561 741 567 838 205 108 55 375 689 621 809 638 619 308 910 373 673 403 326 967 883 589 674 772 963 416 989 195 432 880 302 931 422 339 179 828 582 188 82 674 591 651 52 731 299 533 958 503 534 929 117 408 968 944 951 229 125 199 308 787 527 346 255 292 244 293 500 714 899 69 180 942 331 726 450 358 979 453 111 788 341 191 814 128 624 561 720 492 653 …
Output: 829736

Example 2:

Input: 2589 806 402 882 953 627 78 608 669 213 235 81 394 482 440 684 754 317 264 463 518 972 501 491 177 801 298 871 975 805 391 698 451 722 523 469 799 787 230 424 515 279 711 737 988 891 613 878 367 96 525 576 493 78 57 873 895 398 512 138 705 16 826 249 805 215 492 380 643 120 959 715 6 485 175 265 48 686 386 534 467 964 169 362 286 166 222 81 84 209 885 789 557 150 1 980 648 512 509 123 508 805 163 728 319 695 584 633 455 917 868 597 628 428 113 609 722 999 174 244 854 258 749 626 725 882 588 673 891 667 83 777 850 662 946 287 845 741 880 500 732 386 734 49 595 786 798 388 657 981 872 800 874 763 100 819 73 571 855 327 248 527 692 937 650 819 888 396 402 543 718 442 557 392 146 73 910 546 126 722 39 947 648 710 747 321 399 480 812 845 563 741 141 61 581 935 641 302 771 334 156 471 338 761 22…
Output: 410482

Example 3:

Input: 191 165 362 129 1000 318 471 332 413 200 945 435 642 130 171 163 836 710 835 274 618 15 564 908 704 552 372 411 663 678 307 276 279 235 984 912 185 983 690 684 951 395 877 121 383 209 767 874 914 20 105 413 810 673 825 667 706 815 472 926 799 963 114 631 527 912 388 735 971 483 847 618 148 27 946 319 915 275 840 839 229 208 426 898 451 690 498 937 133 535 388 884 455 897 870 443 667 579 676 237 516 552 661 50 277 38 396 291 419 108 879 805 909 233 466 693 995 28 605 694 131 64 917 458 651 239 167 44 200 306 433 263 243 841 509 141 209 377 822 749 568 971 101 16 117 47 998 706 357 207 282 520 974 742 256 784 281 292 428 484 834 559 14 191 993 184 363 280 735 76 606 588 686 455 597 770 755 580 980 226 928 339 606 934 263 541 695 307 731 305 32 729 147
Output: 86996

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Freya and the Ember ribbons - MEDIUM Coding Problem | CodeTikki