CT49983

Admiral's Faded scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the trading post of Goldmeadow, someone must tally the donation drive. This year the task falls to Admiral, armed only with the scrolls 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 <= 2340; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 2099 256 964059570 879718089 72559616 592054112 23426836 889100041 322480855 624114637 225435497 286132269 329831474 632839821 634988555 832531030 965470711 976199049 915990914 423015094 177548329 356142974 695540470 790904045 956755931 899376374 881598984 101906564 632694155 395033489 654745060 91278274 390583455 418900688 12121906 945599373 177791581 514989711 704795747 368585377 819903031 714753238 481506207 735937108 53797692 260378435 626584997 507580918 641101190 950588467 821964361 236354273 811264745 75396033 993495169 426383395 582741594 950285159 869913865 817470018 209696842 811345159 514324402 323148515 868425016 835696346 785318017 43796877 561140639 317494377 974941273 643085218 822478548 789203571 246356193 613854711 545335865 939811076 390190460 274422449 563348257 84049302…
Output: 139781485122

Example 2:

Input: 676 281 585913187 513864132 38549292 413140302 858824773 568309942 777230316 678881585 514752147 90116680 29167783 71298366 888429942 111550829 504594303 984417344 521678901 747574553 269677104 696106498 191662742 799078871 481409773 339209030 625040633 72400950 426597545 139317024 321099610 698124468 710274433 708639675 773543842 118515469 381557742 910163529 644604797 842437304 787593770 92083919 516460862 589986459 275935216 164326394 421822939 487402791 105001251 314241417 928167389 787306172 215383277 487793331 626319728 669438070 836866396 353928774 969477999 381398176 944503503 598610503 213318998 991355630 346486440 51067295 904849400 523017339 416700794 785304664 205779818 435028468 62450198 524855817 -896608 753509460 263599700 614065761 114156068 387241405 580656182 285404080 98…
Output: 151005971718

Example 3:

Input: 1458 20 319559622 326734289 107238028 991610338 724651006 807458202 518174663 185227227 400942380 428211664 65782190 133554000 495697540 122006250 595324309 665814278 475665265 868882303 744200615 998655510 81089978 51236943 649996427 328044034 195991273 207746041 625800975 558966988 615854952 705199366 305513496 395146630 331410909 12740012 912215854 170200347 396390823 393850869 232420329 373776601 928103228 823165203 418416339 925751951 484610512 740983031 446728230 99986473 187283278 513018984 562883613 382026862 548838405 20049636 271098149 372574433 349606116 9473053 794224259 500234606 652446391 885799136 906197912 653626838 408626045 530560234 626194319 779556402 209055028 555033847 754110029 455245973 222489297 826144723 79255000 529987466 61147071 962969849 9376042 889436191 8921…
Output: 14366594332

Constraints:

1 <= k <= n <= 2340; -1000000 <= a[i] <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Admiral's Faded scrolls - MEDIUM Coding Problem | CodeTikki