CT45890

Yusuf's Dusky segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The clerk Yusuf has been asked to track the breeding season. On the desk lies a long table of segments readings. 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 <= 3033; 1 <= a[i] <= 1000000000.

Example 1:

Input: 1311 1036 295174526 81535561 399736453 708997561 478515561 450579469 541103113 480633621 99714452 605079716 597121696 229406384 157514767 789999127 871794534 759845308 219437810 236940995 161186956 845715057 422652542 320200366 56857010 693173350 678532074 71272867 340719516 606775703 127563061 711623993 342860932 754789699 837506466 343795000 934882400 338273356 836579644 618852774 910626337 460453342 943760257 835093652 699731606 796116129 73765249 985342385 912603218 629266785 513858207 250487787 236921253 486209009 749319158 262663226 415913699 919492416 279559495 989515784 552424576 770873460 235426628 647586128 532506758 876979066 606838785 389671953 424037718 577638807 560593887 229669363 887071897 961253710 43077821 383548590 985978099 931576242 751072865 685001457 685285178 418412…
Output: 519099745484

Example 2:

Input: 460 52 57475007 204758263 114588628 52718628 907161182 616307097 282676329 673276480 21867745 236778018 418961881 716122586 501796654 427537650 475884110 648953771 368816388 629403105 928463020 101153168 609884323 226995794 959706550 163583345 607487058 765706709 108772653 728515755 729899408 400346492 653753736 37237749 626219804 490433168 94382471 362889760 226903272 876779560 735043655 279085653 633202760 562755771 771617172 488356431 420063132 595453883 966311181 464020224 733973718 39658511 960023074 685984785 992429473 502480414 83204729 780719302 503218979 587718931 570929190 981935160 582496468 817577269 856425782 343412929 552889922 277231351 581039601 791733506 636733236 987317593 861780635 365707062 308330761 190054661 220729888 378108537 834702267 871007206 896301612 677995144 …
Output: 30420100363

Example 3:

Input: 887 875 917208391 484305594 518871631 610956115 866465320 904078616 689174810 602537219 76181367 208617375 140030369 4569410 415037852 996428447 484190384 144277138 839084515 216432142 846991524 645220581 789447803 169635239 288273377 503460274 50179264 276235844 679434625 803326262 270400973 649792489 354253102 35962711 395913030 985318133 117382471 873045486 989638074 417184702 691813765 586253693 685169742 217156913 894941263 706728019 354116890 381824084 981378597 353669093 879424951 643884816 674462149 295951643 841085844 224511181 651779176 862258107 205756947 189805664 691145247 110555891 514114123 800208525 319237714 671586813 758283936 572075981 490575472 446588417 792210927 3771964 753739874 198345237 513291978 871691052 934634267 836654218 184061353 612021650 725544422 91578236 …
Output: 429199253024

Constraints:

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

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