CT46416

Silas Counts the windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Silas the accountant watches over the garden city of Petalbrook's stores of windows. A careful computation stands between order and chaos. 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 <= 2397; 1 <= a[i] <= 1000000000.

Example 1:

Input: 528 192 586506759 705337561 418205359 278984702 639203454 105913263 915391183 638079196 130483301 740232838 832715826 474507378 672023101 164294400 995148130 503289772 415653417 74645354 606893619 619840812 395858086 743280371 546463223 497861124 543251336 298922368 809270020 915461902 302548465 50533032 853084 825110707 467572561 284969067 604879984 399560559 469860757 985493374 512176172 238860726 770257819 185588950 715120540 478846749 392519774 918247880 138720734 325791945 880360548 111157478 404519565 540157401 232121590 257786777 202399069 873354036 453208702 31858176 462304525 181777374 527546613 98916575 589559547 121576102 123107184 801198719 444656694 613313459 822236770 638284835 246561584 992200616 343324578 877671715 253286238 499956232 434688079 461034948 962408767 369007336…
Output: 102437250315

Example 2:

Input: 273 153 368952104 534864732 485531100 879528558 684334846 270087899 73901206 764621734 52834308 560432155 192749260 387654486 842577118 928218374 328512833 589305948 677684342 535986591 507928959 677645470 247315809 768671315 756902744 11039776 934063776 619772575 691577639 624330483 983283694 975145690 948234705 311640565 946962280 971462768 342821355 708662144 607484128 35235126 300110218 853384532 813875558 688979063 453518891 509809578 82449319 696885017 544397897 569854245 375054274 441012690 314806295 647710027 300599450 426194158 564758712 197726446 522474318 927183885 326716741 188203082 253507886 522729346 28656732 440154944 438705478 202215352 949288395 846971780 882412110 347191641 246883163 615610728 403538985 948748409 996499770 44950540 195902788 726664636 42625236 956504323 …
Output: 78277831809

Example 3:

Input: 1058 747 384062088 384759367 221884459 775717386 15474908 22948816 841051681 394297641 776540239 449779993 80535991 780184928 505777810 102276091 365956911 534805835 467298807 760409351 703002257 386430849 659576650 14722843 460496015 595664559 797868067 91625474 348436845 633674188 163186759 98077008 146047476 191547040 253474265 692323130 574530118 757222680 57993453 493331413 126862772 385693431 491856284 415164542 492602657 960258326 669227630 661829780 408473050 391202553 996757836 457632325 189889415 578945356 708393688 808074761 677672951 460407502 427217167 143346565 601651050 994884907 289199721 13581365 282013737 522444744 388913897 997554857 365989816 124177591 589261102 776289686 174891786 337269675 333832793 268334614 469248979 918553260 488246530 419128154 245815931 26095720 …
Output: 371886101168

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Silas Counts the windows - MEDIUM Coding Problem | CodeTikki