CT41807

Lysander's Fixed Window Peak Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Lysander found an old ledger of panels in the tannery attic at the dune sea of Caravanrest. The margin notes pose a precise question. 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 <= 2733; 1 <= a[i] <= 1000000.

Example 1:

Input: 596 327 638504 672732 274252 271262 483294 419522 72641 960259 475936 560015 355437 905876 697983 474547 826491 382349 296012 600535 906759 245008 334188 230874 853723 118387 251003 406655 445306 497692 885521 552184 769811 734519 832373 131003 390786 217471 10703 756542 601130 383409 957428 233577 492022 105760 642986 225872 961371 461590 808314 188875 566996 222968 470244 791257 895284 973894 172080 818592 825237 98393 5512 75138 915355 85469 111396 249153 857360 968514 547166 890145 979121 620821 16997 551621 112771 649267 815817 759070 258760 494963 423845 593450 128526 324105 309400 163981 781454 260069 788815 994054 641586 776719 727910 745780 153191 283458 370641 871081 608471 730866 941019 321966 884717 374161 849867 638660 642287 742663 221201 615558 975989 633321 616645 628472 96…
Output: 175538518

Example 2:

Input: 2138 620 49746 554181 156407 546279 505764 104797 922827 573263 527003 43921 331565 413308 747670 67856 818696 752750 153821 190573 375686 920211 753845 372134 401577 475958 801294 57191 950460 351786 652544 50365 525220 37401 455165 71665 414176 264349 262863 642537 893411 759360 734255 425630 413586 727621 7191 362641 405589 221123 285622 993877 255286 114724 507184 398859 525343 98963 785498 190425 306235 927881 115993 136287 252369 824260 535789 658299 390065 874880 439639 721374 870154 810433 47210 56772 94850 105158 763138 749307 196774 536972 927327 573592 429823 328411 468886 254490 148878 749614 345917 53932 761187 307297 229245 102258 46857 792486 45079 310860 310519 330539 36111 778538 648758 603404 264376 792047 968462 611313 933021 305584 271179 899569 771724 974980 463490 695…
Output: 320012327

Example 3:

Input: 2250 1553 716905 17787 920833 679542 573151 288194 817551 943667 489244 759147 644459 897614 324426 972906 667286 512280 724608 116281 520291 867344 912097 175457 122045 777884 664655 954631 84707 9183 309861 766747 947372 809966 50744 292762 555586 544062 952866 758212 631739 642235 827448 787873 587081 577426 79670 684443 870942 292970 104275 993707 415230 100791 23072 396849 660057 528471 592320 175087 828495 643619 146609 689038 905069 134022 742436 525723 363919 852481 861698 730379 521682 906878 238062 309783 659882 303423 780309 815472 443770 188188 719619 793084 129534 433585 386584 9581 61815 23232 550 404183 201307 624508 6998 371758 725857 159716 417865 860445 937562 422433 687709 418568 829527 344419 453373 787971 31456 378971 514255 72509 113137 415332 647280 707305 279372 163…
Output: 757275145

Constraints:

1 <= k <= n <= 2733; 1 <= a[i] <= 1000000.

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