CT50541

Mason's Pearl Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the coral atoll of Pearldeep pays by the answer, and Mason intends to earn it. First: the full register of segments. 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 <= 3064; 0 <= a[i] <= 1000000000.

Example 1:

Input: 46 6 141263202 515427750 5324347 615383678 656781016 604103759 951372093 897391732 791277570 408298493 373564256 208705300 419561429 223433466 769109029 708947541 986741563 6060308 290644795 439404291 433331660 549505677 536438101 648273845 199033864 74761750 720498793 627778266 234309453 634344756 851635897 294067892 181108758 225094793 927185194 136662170 524033453 368179899 659414689 541485198 428484834 257777181 546145252 170888978 389411357 219632982
Output: 4516309848

Example 2:

Input: 2519 1841 746388416 255916348 153311091 952085676 975639645 962139491 332809145 172107611 205717924 545748688 184880673 257154345 925647993 603843566 780963177 807684199 974104700 379038258 891377726 360907750 470069277 370898048 497883472 72195719 945920170 207568829 982818829 143168442 200979322 912630804 924664787 79162564 896674871 559009147 81254215 850685751 160272147 870569186 504546782 923939250 513957674 404940409 414333765 643435904 906366887 928210800 98683953 375292622 512076368 127065180 441041778 70048535 676442393 410339741 268643946 923420254 108138730 92677417 428657843 356029380 215268261 918739457 245875375 447563282 514750662 168998272 710042507 188579796 238048558 196869952 252113136 633853233 157180091 489713765 667809395 594860611 375039521 591203238 468954881 112038…
Output: 922062249961

Example 3:

Input: 1807 73 736596671 790624477 50980604 786702663 480641223 79833740 508563800 290601428 445570790 987212880 796888646 993112338 176613261 71783262 948850962 734817023 545563777 493353371 922520938 244205508 849154241 337613257 410698904 357576361 355973463 531482922 254684217 464378486 648244867 481342936 955007454 573617428 40871871 945706782 657072076 266108267 298592960 117591184 180511091 990921226 902672015 369430458 123111886 818819421 152587955 419846433 478338930 733962884 6293638 885525809 214169740 585062940 663748377 257945685 990801619 592577594 679137782 24670039 625372192 325021276 504944035 759660817 295714700 159961603 309740870 276847574 463030609 662478130 474753631 974664083 86606314 695119326 539055682 424003658 672012992 581652771 684882950 809928007 121593237 721277815 …
Output: 40891766324

Constraints:

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

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