CT29062

Crystal scrolls Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the crystal caves of Luminar opens only for a perfect tally of scrolls. Archivist means to find out. 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 <= 1021; 0 <= a[i] <= 1000000.

Example 1:

Input: 9 3 642248 517530 373507 969679 36549 832770 6228 641232 675895
Output: 1860716

Example 2:

Input: 706 605 587730 536151 691793 451264 581292 128380 298406 184775 155721 105784 406348 654210 58380 423357 12884 938522 427816 238172 455950 280803 57335 459855 21411 408770 8233 800825 900064 754356 788154 742153 403204 964624 120479 253390 143387 54177 270427 492406 967089 895552 746428 435830 831642 721391 91523 598778 926316 764392 708279 429138 507249 803711 570868 343899 677598 325219 559717 794973 148204 123534 835786 672530 499421 835631 526032 994283 707827 693247 415614 236884 290042 649006 134996 481450 883101 326331 966160 391168 547961 316268 666365 121177 565635 695849 977250 510096 23052 258021 883848 920963 911099 454705 251734 620877 600343 253082 424214 309766 679188 626028 737220 321841 85524 494053 931268 650232 202619 419552 68815 51703 164769 536665 419274 197153 695334…
Output: 294744729

Example 3:

Input: 29 28 287765 83943 182728 465524 511199 360139 768829 943783 200586 359684 347402 884856 225342 767390 569234 751256 136139 507252 946168 65336 32817 224224 909719 705644 608449 123832 465983 33887 653477
Output: 12834822

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Crystal scrolls Fixed Window Peak - MEDIUM Coding Problem | CodeTikki