CT52548

The scrolls at Deepwater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the fjord village of Deepwater as Sarla unrolls the day's manifest of scrolls. The tally will decide the next shipment. 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 <= 1117; 0 <= a[i] <= 1000000.

Example 1:

Input: 784 530 586289 448727 356243 4627 346946 510839 126520 604593 485108 50334 517894 971906 181104 939306 270543 59440 902940 434983 752533 422028 12362 360427 825711 707371 334942 737445 872096 665517 822912 405777 506882 734775 382277 746987 111550 695169 370027 954635 326033 949081 456124 901757 168947 208291 404783 704642 74524 368776 830 549253 327927 177634 705497 887645 786720 629032 861462 284550 547339 482707 92604 916310 335365 85673 289059 275836 803117 10496 614799 636775 165000 786251 755525 497188 370000 147623 594975 559565 71341 489218 248673 209010 467240 423729 82736 529164 728019 569640 579101 41106 798784 581016 19206 333688 786461 702627 219881 647946 904591 754774 794461 402409 925234 483026 469707 545693 170978 916272 254498 85715 335325 725859 278555 188873 455299 8068…
Output: 266997867

Example 2:

Input: 903 67 170339 968482 726257 307665 857753 938619 336877 253783 115041 477290 219098 959594 440698 129012 633152 624450 847295 407024 277052 399979 728447 880198 20746 356357 800187 241464 39874 122720 309408 967187 679108 539377 453238 118034 803306 468607 188040 306628 42388 41877 859214 873185 947854 448955 462755 642800 89851 943990 652827 838498 189412 399676 487504 114208 938577 464785 649486 320486 253242 885791 391696 37467 780175 806309 266723 178973 605529 151157 947812 935330 184270 877354 39796 147682 593910 878196 33601 394749 404518 869760 584067 785683 846133 110490 862383 493460 572450 805097 404655 367695 732532 555914 833395 309995 124041 680181 903830 383411 918363 617740 351001 151902 591712 695432 620273 990889 925541 760530 534599 416697 937849 541330 992524 631878 678…
Output: 37752323

Example 3:

Input: 130 57 457329 983537 193071 675864 777132 865533 75072 722524 415849 618244 587976 621423 403637 67050 549601 460331 370439 189967 271050 789976 448784 474383 47684 72378 413853 207443 203225 399841 69077 226070 389299 222819 440959 343306 917704 587732 951712 95408 300067 448884 50393 688997 682657 448455 814981 431278 839855 337820 895406 350167 7854 387178 424601 870673 387413 834474 924991 804147 632266 818677 158076 326238 562150 463464 279267 13511 325660 987045 330162 261476 488397 253865 88051 649232 814090 848167 985999 139891 301014 921626 197615 60479 575347 785785 998279 604905 612504 397624 274836 584001 891054 861067 50863 544270 392010 671447 587976 206411 802418 665098 121457 499459 561131 396373 670800 566960 569611 946239 632313 148013 246514 826309 974833 984477 954131 7…
Output: 30622955

Constraints:

1 <= k <= n <= 1117; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
The scrolls at Deepwater - MEDIUM Coding Problem | CodeTikki