CT50077

The Fixed Window Peak of Rootwater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Tina found an old ledger of segments in the studio attic at the mangrove channels of Rootwater. The margin notes pose a precise question. 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 <= 3555; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 2900 86 634851603 794147478 535037262 722906979 358737330 45426414 966263258 98859334 237483695 245557065 256961644 596335378 144800172 692254214 289356240 244593201 610327262 853014763 774518581 108045146 132391828 139945414 646822290 847305833 685871763 178389123 376111278 263493517 354052593 482720272 781899985 129689899 320785623 520207219 773729277 796656471 799842445 13647190 406056493 211904400 4251380 115869006 782850778 883641783 523778578 845860032 106714271 812603447 829781949 888397775 491140712 404484631 700615740 621514978 325965760 204765721 215944700 675593555 622980996 157441803 857284070 83178278 351260684 91938746 607279318 588470485 368552473 44713120 419283352 337100813 650541223 61365748 402160676 24468306 215859095 911494794 276682893 703098637 404470433 485797248 47…
Output: 49019535493

Example 2:

Input: 1357 82 489396856 894921269 7215482 870842932 127658602 755876896 909453991 369333267 435871391 271510880 57384432 509820953 823110262 700519879 394700161 649801478 337482098 595117326 640586131 436001403 64619046 345158912 75782218 580323437 821723916 142041957 602274752 424060233 185762343 902013078 893922989 36209817 645209214 308713973 683203519 180806763 808073768 195483823 51080630 159048558 500712021 54997715 434359968 570135142 284778572 899146353 408204766 851598306 235309785 848981127 467174944 452268037 82488682 859464587 512354667 162393744 599230958 149895365 77248847 992273407 518910862 768670153 698038349 477961635 150243575 424886563 990546737 133037419 747274368 885698371 236154097 690898090 163692655 678727847 928441822 666663356 570422281 600779140 871790097 387562453 36…
Output: 48846178837

Example 3:

Input: 2300 2086 402991074 998559911 134426181 559210676 868334665 598452974 19110493 732735077 783420482 393360107 683364464 360288932 520162677 864314049 225352553 960423625 29562662 871538689 211369644 411668103 893786446 637195144 350419700 800580908 715936665 669239594 722126240 702776166 798420151 747308766 458251320 395959324 682028270 845957073 689633205 136718145 376317948 775511024 136633300 742492241 955397165 160477319 169075739 480919567 980134561 10861370 154098263 472141956 282788071 97276577 331351697 545094060 842284278 955758905 84478617 754950171 245697197 518796074 289521867 214993868 463404726 276075247 743393820 188675479 614277841 91393095 982225919 271599270 255723203 662947300 193237095 30574452 80631647 24716004 902669478 859168318 637416638 742062866 116559843 918888414…
Output: 1047823410322

Constraints:

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

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