CT56535

The Fixed Window Peak of the Whispering scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the otter slides of Sleekwater close for winter, Leon must finish the scrolls ledger - one figure at a time. 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 <= 3878; 1 <= a[i] <= 1000000000.

Example 1:

Input: 1638 358 477590267 322373245 205985232 602522862 195583185 204853482 486326731 429648327 730652827 189736538 118971970 528880757 738240782 348794022 365172828 909555528 136976674 220222572 686117422 182940979 57432800 19064846 204035630 180000390 172236656 778553604 16798911 207018122 660978285 131765533 521813884 576671450 618374975 751838522 926416188 413218844 204963881 2309728 531519996 297458990 101913503 45826164 853712491 779809853 232719483 554236451 985053415 186571073 391050287 705301151 679113712 548948356 529085323 86496907 516726100 212557131 818579618 755348104 775480332 167017063 230523780 259706547 417717822 295421556 810328091 879486166 734301580 650898911 510105681 597670959 881936608 426196219 182799683 223858923 838696728 788701070 416882573 949747321 853524842 80738660…
Output: 193878425552

Example 2:

Input: 3534 1205 537471961 59260132 659708816 709796230 73559630 697446897 765909052 917509043 822828556 961978769 732992175 520853520 760749747 139284470 872324123 1403561 878632737 466450007 323815280 239467242 943047222 515837005 740757454 486554622 173525097 606705973 212433549 300501409 356121574 874902250 932354786 912483489 359153499 168018813 93707039 468772078 822339890 990694103 848201443 556045310 81096321 860813476 992460358 814727850 860974237 291418772 511659660 156356738 888462903 372908361 5883385 560407771 505294534 61814138 166992245 806782122 537325436 575240996 111084511 935120779 69483863 104171310 561759366 713956015 839486575 376696784 797069057 637919045 390028340 829582675 653178072 529428864 657727191 162281011 671543850 951222423 751354107 27461765 129382407 295963099 5…
Output: 624763303379

Example 3:

Input: 3601 200 460898275 127556823 900088031 81687091 808777921 541678147 277655571 529001493 796680556 818408320 272916296 197281816 174265075 879762509 257405577 229183764 61183220 706176292 395964948 822729606 723196368 110618481 2639757 656468290 103980521 301884365 963021248 862925650 205219336 184661214 631586043 983243970 178756222 176711985 219124976 479323113 695050454 579270352 689907905 330296374 532046321 906680879 106101072 205768814 43198800 277506884 754194166 153035982 223401661 472020177 424333450 536029805 26089101 355830182 533907895 512179577 536478209 623063715 22601218 215633522 746096928 298388410 117403292 297616416 174039977 26584938 880946454 339661025 678005474 63483876 964396473 5965998 244500549 619091561 718572267 101335953 693460376 983014555 628561958 316918947 38…
Output: 111946240159

Constraints:

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

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