CT52326

The Fixed Window Peak of the Teal windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the quartz ridge of Glimmerfell with crates of windows, and Ivan the inventory keeper must account for every last one. 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 <= 2589; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1530 244 938210170 746654710 773616867 950555052 400639620 696009697 846762831 304928063 530426544 991989513 46164986 772550516 581012482 201079377 357051784 460744041 248491867 553159375 466129433 130614279 755096967 565639685 994499824 473842181 822218505 53640581 395299774 763169129 92666579 222854710 81329693 714399377 999242962 318192626 957839054 995265786 418917670 489335201 703090746 695060709 845432744 201053711 600404646 928159897 365892751 561872048 263721539 384246626 304081970 661541272 375705148 572884486 316142867 951031576 601384664 622103234 420400846 496508444 886267457 703006607 641609212 270971888 682355685 880409503 317073536 279830857 593329819 491411800 499861126 892366725 285130945 649134480 91453570 421449378 228227061 853490319 904015738 875997892 81009513 8191494…
Output: 129898064347

Example 2:

Input: 690 197 935392760 112413041 691177477 87704898 705010499 670608100 429093318 568226457 763283912 628523969 699024922 591089677 813435917 149387787 752140962 495057702 480250527 155531469 289119287 691284466 306007139 586646024 997175076 131341698 704391139 325924293 509108716 688226333 277560441 543164464 743791965 61195428 399419927 46939049 205601891 906965258 94808960 335090786 831795523 931601731 287203239 107324142 824863065 590946639 139158525 93266154 351141795 596753186 845937266 366337615 480475161 315519848 779271091 428227319 706883142 19657639 510395679 134960605 902570951 260164701 318126346 333812535 470449758 548276566 68385912 993140734 572304017 632358322 618306245 732839765 559076134 225037315 125640889 151875720 188062957 238605542 652905618 251964733 224219995 1412837 4…
Output: 105179245851

Example 3:

Input: 1776 996 838715074 781273648 924873929 156288795 373024242 992708683 730197367 178006579 560527887 485525262 655215774 984043271 170356044 335753168 394078592 891906730 495211899 482299878 101789332 827207212 645933204 71867269 408979330 362745858 555221619 432539585 421520729 348337258 462897308 348057567 435625512 195305904 284165135 88979750 631665104 273129939 784352938 446454595 707452541 426012840 370567389 525690780 186250743 412936716 84803463 130866833 905655995 227932530 881497914 872267870 385469161 772950099 353563796 399184907 718543822 122502729 305641560 293439212 951194140 774838641 145293897 250424970 274970165 480453624 546422730 812510739 321721733 631272374 42510782 679305685 158754738 161678682 223504923 472626145 880022912 680826340 649331940 950325447 282953705 46900…
Output: 508923540859

Constraints:

1 <= k <= n <= 2589; -1000000 <= a[i] <= 1000000000.

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