CT48799

The Timeworn Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the kelp forests of Tangledeep, Aria studies rows of scrolls entries. One clean number will settle the guild's oldest argument. 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 <= 3218; 0 <= a[i] <= 1000000000.

Example 1:

Input: 2142 1505 184661609 507347652 881099992 226747233 211311904 796159520 351239948 961860086 860238553 474117170 179608724 502936593 545131139 221593171 449521625 255277043 720306799 591098052 663723127 937959077 605845668 307768604 576664415 967005232 398052849 964900607 597383570 140548035 253284155 88379070 688730792 638588456 971930673 262053351 403614257 959014369 668651221 901466295 56274389 533405406 972308509 545467206 320505201 73376872 22542792 529236639 971351447 736944691 1895862 459790385 554142063 24842032 638191846 437112936 663561231 572173370 250000858 695363606 449755036 470497640 721894276 338067597 281478742 722996269 195393096 718077294 86254398 366674258 647913220 582327052 224392990 381992539 488184848 645200452 926546894 133646718 899194721 713638336 95072531 437535003…
Output: 747839927758

Example 2:

Input: 455 276 777344054 404813621 701115331 996756746 375393033 410414634 466324998 325464840 141086932 246014652 39762025 417432534 986763561 391802178 791684308 2690388 200429423 18507701 848311136 758438487 935378915 122239613 87770688 332009101 459117436 234756121 867291179 823532511 566994709 159655153 415942321 736410528 237552988 760404058 910375350 238253360 90165154 107953795 992827612 549363513 894468520 619610768 217274412 69396749 682083858 451725663 546529373 365704337 807833854 825298034 608195092 959972952 14712554 569954426 907021970 568174699 268269877 768339645 475304275 785995344 187442301 13308470 620202675 412525993 767585837 700895702 515516740 191238552 591464388 333913316 188901461 27790174 119197060 983734223 544763588 828556279 552329940 181557397 149972908 723039893 40…
Output: 139082692653

Example 3:

Input: 686 434 473161847 545465884 48982908 225192930 777330960 916085356 595491256 585993990 212834867 614861808 726073495 98300785 557056098 234982130 586961079 744328456 729638600 601301889 159746381 128414022 870671715 712166302 254406095 777878434 412074960 567388510 490947437 589447733 652018463 270878013 26368176 828054727 792868554 164471872 491907273 392476764 237605681 43346001 518584119 291717314 795668905 670102654 90201337 268037958 185288584 336794120 778974518 954584737 567949337 385348083 219623020 161199155 153122741 868289946 733388698 714861811 242279022 559834522 957794238 452889214 850754324 265076843 656915553 572460137 378846050 333289005 355113966 833407847 621186635 481479226 426000440 418774977 209702018 15155549 893784747 43406284 265771678 69024164 890759668 980674871 …
Output: 218122818625

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Timeworn Fixed Window Peak - MEDIUM Coding Problem | CodeTikki