CT38889

Gita's Ledger of ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Gita runs the salt store at the cinnabar mines of Vermilion. Today the books show a list of ribbons, and the numbers must be worked out before sundown. 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 <= 1505; 1 <= a[i] <= 1000000000.

Example 1:

Input: 1072 1046 243653760 389527365 199212457 934234939 383236672 468021386 722614655 681098628 963207786 214265413 846904877 953201906 296116883 322299753 867095624 834741950 949503413 661655999 167973957 436747606 200565863 481283645 364763093 895106953 755595833 187154954 244621543 80887265 573811924 276847856 355424047 671355368 270978356 227405421 249768410 875670135 191711532 350783326 23401849 104949253 957961393 56267120 651827327 982874444 855125228 258243543 2759866 714935810 960822634 805015855 218065267 841162821 524669230 196383451 393393170 294054656 18703894 43264421 863286792 747662017 561380397 665725274 821962111 163680951 356217247 418898273 207218574 880945953 163235489 56874365 270197764 396548311 686714503 240121504 137861144 703947403 575415701 626674023 735061114 7317400 …
Output: 522713213966

Example 2:

Input: 1292 926 917280451 534944583 143309257 886886696 577610875 726852162 36859799 134160449 887304312 126929759 348680122 461961676 792249240 820144101 89229855 310225091 137959102 707463202 135134685 623527568 142203578 196650877 717022182 560958420 884114920 373470866 928222086 36185100 362909899 945108286 731588918 994436643 567916307 58437915 342903677 347896224 769184305 527764853 7894452 268371262 43294603 134853481 565646078 53357862 490780740 28937688 938038600 457382889 863139294 485586306 257860014 439398772 917858201 97319285 819129186 337715157 116211418 566344540 781623107 249185059 586332365 103712790 589825007 450899687 173588072 584043656 213994188 913204475 959486958 769351236 945755440 846871880 716642450 869468145 99469337 845321671 848998497 307457643 440263205 613514467 48…
Output: 472298966965

Example 3:

Input: 1051 154 43461053 945126164 705984240 579956810 559967005 24045109 135702263 26729085 774932232 955683365 535669432 750701863 780935247 947376284 725129757 364266555 374672410 998666240 721110071 145422856 220237479 628013344 102888198 220442550 486204236 1049939 756786994 573884335 109745582 227813777 845093200 952304527 757908163 686322824 770034933 330070520 208598455 854263979 867789366 365819858 416342045 423172745 265053464 863657199 541347779 173923485 876664540 375495233 798799814 96216964 618233092 704915343 420024125 94871851 449807692 359191021 115864626 727328260 806207192 236269233 680874584 876686216 226373843 880414641 553762773 119279148 930351666 159058760 152321700 74613434 1829970 759548293 340980720 297976242 560919610 56511129 894630221 716629259 934042454 57673370 671…
Output: 84929961272

Constraints:

1 <= k <= n <= 1505; 1 <= a[i] <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Gita's Ledger of ribbons - MEDIUM Coding Problem | CodeTikki