CT53121

Tempest scrolls Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

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

Example 1:

Input: 630 490 578459 183929 285850 661458 61397 319991 462469 541012 34581 913044 680642 690663 686282 6469 382700 649577 689958 23580 849063 878262 223794 14245 388025 993648 556198 63728 332352 962667 294051 558497 429121 140177 143477 411033 256700 309385 638377 780612 633016 8231 469815 581800 709793 167975 139624 991672 449464 799229 693335 671205 664866 755810 28864 24670 130533 963611 184406 415015 736810 821433 471928 566267 98399 916861 915969 322432 138855 446165 639172 806646 747663 908101 19375 448853 656663 336244 3163 848896 747542 241658 895841 342951 724785 650891 175497 333541 167148 740176 277400 192129 872774 849264 922616 469928 68929 77708 817257 146385 102199 456421 475298 675026 232731 351410 551970 462365 50924 728346 177552 513122 40818 659070 125199 690632 682009 81462 …
Output: 242368010

Example 2:

Input: 1152 168 105692 874152 455918 792498 580730 274834 601200 562818 567961 144548 597950 706116 155076 862432 199987 522057 244760 121782 221562 649291 696648 271048 763540 189977 914838 957091 494370 946814 422730 881108 402680 434766 470258 845244 426996 541137 43456 590010 174091 199946 968665 167916 11935 182371 432881 876089 578041 687751 297619 747767 398033 653956 688414 244096 509220 148329 260855 637008 121381 76157 87510 809958 964196 900957 71982 11463 328432 696928 348277 787871 660005 879686 444218 349588 340728 516512 452413 340002 923868 589876 725924 217204 375218 537179 830060 966558 664711 199320 213729 913285 157129 761825 445324 841073 990068 7087 450980 602361 327705 723139 512632 962835 612459 261797 490682 800912 155243 582089 865153 509126 174049 779553 90395 853227 46…
Output: 89709588

Example 3:

Input: 14 8 8939 400966 438767 973792 452912 947700 823563 587424 631205 370384 798985 200362 154906 592909
Output: 5585965

Constraints:

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

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