CT48403

Ishaan Counts the ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the mulberry rows of Silkmead, someone must prepare the guildmaster's brief. This year the task falls to Ishaan, armed only with the ribbons 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 <= 1039; 0 <= a[i] <= 1000000000.

Example 1:

Input: 397 46 551370851 617726756 193991342 638698598 271805990 662826153 170112206 751672075 498379602 882620757 329524770 924322105 831896387 684875589 136400296 624383275 165413297 852723490 978798818 819118668 560091127 275949370 119966168 989043002 652364021 707634640 832476440 267445691 984640829 943277469 888393580 967069228 43769143 190602762 285951308 88360987 951787916 827775845 348479040 413724846 298124792 855809799 790933527 436882655 690904859 909506901 348735513 906607504 371491099 618219239 983503631 842314559 364664909 385160319 93721722 904383457 428026729 102622742 613992160 734146050 125318664 145823240 441235353 63954703 46446908 990002482 686429639 175162010 911668840 987347353 607968718 368278164 419730538 733486961 390330529 302749205 999919751 398622357 503970316 57873358…
Output: 28236631528

Example 2:

Input: 279 221 93883731 795566446 418646917 183459709 35079759 555612445 368101219 859518625 201478679 124590476 375935505 714005699 243658863 977889793 887368722 338648778 820563500 954119349 648835288 957712610 365347557 581991514 325437073 670424691 888915446 971766474 460224609 62178212 348175622 306131474 700379305 970740336 366902834 561608325 160494834 641224560 557052427 150648520 582508226 842781218 747043006 84358535 908606567 569024207 979839052 335626030 72194711 288554892 62644509 302222353 426143210 530689966 408398483 656932375 946861536 731709249 592101853 450842745 733181865 652051376 644771640 102354974 240172417 37152768 494091624 937995841 123759015 759928899 992083717 749006715 135651700 422429997 572033008 262955094 914303471 832128355 672247398 383133803 615724055 34091265 …
Output: 109446654235

Example 3:

Input: 23 2 755043819 33973862 254496975 526618604 549077283 896696391 377308480 193793279 338591630 620704525 440409032 547778161 56508122 467199910 2191195 213110599 90084640 222274081 543563913 943204517 616278851 236178462 115711576
Output: 1559483368

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.