CT54299

The Fixed Window Peak of the Ancient segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the silver mines of Lodebarrow. Archivist spreads the segments records across the table and picks up a sharp pencil. 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 <= 1891; 1 <= a[i] <= 1000000000.

Example 1:

Input: 676 534 838008603 571260083 655060449 839951453 249845996 602686969 971829258 189674713 932648522 94093405 983433545 609334654 532645160 951750519 231082996 188830611 568178700 88664105 999055283 382444710 799233988 384518893 34219203 478325744 336081596 143909410 417972680 413900502 632637107 76318394 50449907 932429751 231424542 128747754 355764465 997926427 979343077 447077942 834994084 209656574 624633547 272939664 8421009 936407899 450766854 397789004 509427794 382792984 190422608 445588880 938966179 275651290 869983359 928412936 838382754 562444921 507421740 613618988 550909110 426584682 796067207 161605565 757063951 280399752 360656153 50441723 37408753 518180357 246255673 737497168 412178579 921044159 44502803 72292073 665360254 200470761 124385795 484439637 225672237 491124208 571…
Output: 272113274459

Example 2:

Input: 1494 1427 46316089 267729649 398273154 864366553 468251216 454182696 291052368 827876624 150811954 904637681 248711245 892119329 659043027 389279015 818222459 399589554 534339458 566717497 537481879 585289138 632932445 990044097 121601159 962899621 615082290 928402763 82668489 380878283 129154443 942726931 224297039 970145371 104073270 589725313 171685566 196265529 526836149 147224415 71516329 505091473 159581295 404671935 593116137 797519130 669619657 791590045 525369435 413948424 220326792 437028031 932414218 926985905 119536194 35386734 422554973 470008890 269608735 990823029 16070899 345936404 157944183 578035570 581820539 745774771 766744501 682720626 338669605 400668006 559722207 392652441 710227314 62946077 897278789 472720142 456896614 185310019 554913234 368115256 596953039 439734…
Output: 723675694790

Example 3:

Input: 404 146 677748175 55126138 694171801 705775128 258790792 684819353 823100957 781811954 640180700 599638093 647295786 409246752 477183485 742522751 694137851 432746235 953164040 910452681 573725354 633451072 343210356 776590574 7995881 126485363 711335576 661369613 164990687 648724629 633819545 608267140 446309508 42612519 566129382 16032314 28103314 444242441 399762829 60307172 556806288 104072368 910116990 271417766 174314299 606196253 401253383 456293170 44369746 949857617 385214853 674087715 669194962 357283048 658198271 635503569 535688413 613297038 805341536 623565230 597759251 676716885 317967327 853898284 344983495 266232655 583169428 41751454 677938893 389414630 559084744 27711162 635866030 465287944 948814281 468327276 685519564 313141265 726198574 805799387 422632406 399381367 67…
Output: 77850210921

Constraints:

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

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