CT51374

The Fixed Window Peak Beneath Glimmerfell

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Odin runs the loom house at the quartz ridge of Glimmerfell. Today the books show a list of scrolls, and the numbers must be worked out before sundown. 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 <= 3044; 0 <= a[i] <= 1000000.

Example 1:

Input: 1675 76 775578 638264 335709 280811 512129 879060 475992 400922 480115 682902 608186 474479 811792 384419 294891 674981 44077 84833 853936 21590 371355 596573 535311 899176 400000 570353 396189 128539 608575 673025 972756 410601 840389 678994 234344 304300 620281 571608 740327 546702 85865 603441 112423 188914 105351 506705 287653 746575 764730 880592 215346 508588 441204 925412 393547 503117 498111 454899 473784 925261 842026 256174 565173 208694 760764 639913 427003 21915 653720 446408 633883 318513 10985 838710 106285 73975 518571 383087 62841 821067 96834 763061 22583 194277 700612 420820 801405 63147 713041 751643 987281 147753 766281 782296 355292 614295 979019 845566 90805 649847 474207 496259 833102 480621 802979 341524 548784 758407 885821 899516 674295 90752 973375 61767 71005 82…
Output: 44205852

Example 2:

Input: 2664 1003 826672 799028 84436 104985 848430 817165 411790 308187 747245 522394 62351 212541 543837 476651 128957 959534 448765 302354 297801 509235 453862 845594 768698 949038 778998 709622 243726 247975 708819 231771 195087 544494 302027 388159 732749 6783 972789 59362 461990 574756 280528 36889 561647 87380 224754 688137 906609 442698 960980 684391 733212 904360 550707 932574 172936 208979 844808 398964 27222 327441 601697 279773 527442 594795 852051 738124 911233 250056 17857 445083 209304 647426 839955 981497 177818 960713 510650 336123 19144 715891 751040 806838 566751 571020 197861 9498 619210 852574 192284 881316 984506 432302 937615 534576 854482 81335 670 597943 159798 110776 625211 464564 241963 39088 261089 93524 174741 339733 963003 216434 393162 769806 619048 381495 42654 2966…
Output: 509220111

Example 3:

Input: 1582 229 14991 116951 551627 694617 288371 176260 613260 615973 520136 88279 896387 145005 649926 230265 404189 302118 809255 757029 272088 613465 753702 330098 183727 872203 107469 235700 215378 647642 519335 589470 639007 412169 901887 902874 646339 41346 944006 446819 536832 816580 231426 617894 419406 908773 45947 906832 990640 409587 418587 197275 52226 360649 390948 893302 507555 456124 385834 368901 244515 773298 855223 341245 546446 833250 440146 844884 209351 401029 546773 494230 261499 694881 207825 254513 64113 482864 12730 33153 469426 814532 2962 558179 368721 836659 679911 619149 266075 198385 440019 924957 763824 722281 640293 198331 563822 645999 143563 6679 64339 834469 633064 919990 272441 936336 780102 688271 873681 921713 624483 297503 610065 277049 371110 610472 370004…
Output: 122566395

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Fixed Window Peak Beneath Glimmerfell - MEDIUM Coding Problem | CodeTikki