CT54131

The Wayward scrolls of Fiora

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the ivory gates of Alabast opens only for a perfect tally of scrolls. Fiora means to find out. 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 <= 3092; 1 <= a[i] <= 1000.

Example 1:

Input: 2213 681 161 794 631 884 858 503 386 38 626 378 676 179 281 878 804 960 415 848 871 301 274 778 415 390 12 213 925 984 470 1000 9 843 389 280 984 169 625 582 526 942 366 872 416 624 991 951 677 33 699 427 405 517 753 861 562 599 405 313 971 900 110 459 10 413 770 731 632 107 100 96 945 162 940 895 823 435 41 518 221 182 516 190 570 399 517 376 433 539 222 224 890 163 725 51 634 554 711 284 825 897 873 615 551 199 476 31 738 323 652 950 657 579 13 966 547 594 724 513 8 380 397 586 734 514 664 529 860 968 785 334 178 164 215 646 3 857 987 708 232 599 427 512 280 579 794 144 809 996 325 696 948 398 700 610 904 863 442 417 756 6 138 768 375 663 920 959 886 335 114 183 137 211 899 453 934 262 973 649 380 169 542 430 263 58 725 999 763 712 342 925 787 240 462 470 380 518 500 796 158 230 801 712 …
Output: 352384

Example 2:

Input: 9 9 407 173 249 827 856 167 670 1 931
Output: 4281

Example 3:

Input: 2828 1347 323 43 875 126 867 989 378 364 590 323 533 104 911 393 770 691 420 382 21 129 566 282 110 623 175 141 102 142 637 550 91 304 450 58 255 805 957 926 196 811 125 806 720 869 578 965 639 741 395 219 909 636 903 634 670 855 783 774 103 599 698 688 689 611 262 978 652 666 541 779 440 320 257 574 841 895 674 949 616 278 279 40 948 265 252 385 558 513 850 453 252 327 232 957 965 943 345 194 632 374 926 55 279 890 893 96 10 638 681 28 41 511 346 805 926 714 648 635 841 277 787 506 123 72 188 843 249 441 229 79 8 927 886 24 265 838 993 385 885 835 857 694 828 956 9 167 36 562 808 833 659 301 862 176 188 315 413 416 435 329 557 442 461 124 922 462 729 940 205 799 35 121 645 654 634 499 579 863 174 850 374 8 410 461 47 149 19 203 68 751 415 363 668 789 245 295 805 841 310 799 25 355 300 225…
Output: 689923

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Wayward scrolls of Fiora - MEDIUM Coding Problem | CodeTikki