CT41341

Lamplighter and the Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the heron rookery of Longlegs; Lamplighter weighs the day's ribbons manifests and starts the calculations. 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 <= 2432; 0 <= a[i] <= 1000000.

Example 1:

Input: 770 400 128273 205489 371332 258313 522639 808810 834606 83526 569081 747609 909431 424991 71314 340114 86461 343100 226333 571905 963138 95853 128012 708131 698256 898583 123305 45505 276605 709022 501727 573675 57119 23595 157274 144200 740586 331422 951770 987908 902778 965068 482872 962033 857109 69941 653467 987411 170993 166765 761643 422636 529804 658453 87308 442414 323250 57062 189161 536626 283974 391358 541491 572097 73973 403881 836523 676152 648901 679575 678826 509862 845116 316397 686823 850724 174063 588918 520171 908171 117408 109007 658068 273606 216437 15617 154137 839004 278447 47830 784410 948696 320708 65744 513970 13705 242521 206248 479238 570644 832375 22605 465421 1867 429457 347675 168271 484018 521991 739346 299856 899494 694751 243844 668675 660070 880088 99183…
Output: 207647563

Example 2:

Input: 335 294 910530 302139 523481 563777 284865 461097 775273 576035 597297 312928 670627 7451 533395 3788 972234 341820 259556 964208 88037 51966 424128 791688 143086 974368 454634 158753 957376 599101 463183 897469 199844 834904 782056 795858 110570 590965 935762 523013 766685 295713 918861 416615 651497 770306 738633 325055 655598 287329 626824 939262 320107 114506 244225 988293 719651 515170 853263 772214 158594 327866 990499 987399 43249 46668 388445 977601 384150 794311 504438 366803 36272 57621 164115 269808 816001 81247 213177 28740 6655 759374 289988 445627 242078 544025 197949 583891 555680 528363 219947 250436 542430 915364 517835 843282 900261 622294 387622 832067 597900 511894 831393 542517 958954 917684 586067 745109 563079 779876 916481 731052 433462 700243 553652 648655 934275 6…
Output: 149898675

Example 3:

Input: 101 34 336726 373641 616729 563902 903348 235576 555554 136499 321776 902224 256131 383419 638848 492530 19035 311523 771715 306514 123872 50044 554550 797018 959941 974161 507601 47329 501260 506221 252893 774015 335507 224773 187575 762646 255442 593029 134282 763219 762628 587620 111315 449022 346437 581831 656867 857324 996142 153083 767353 279185 873941 553873 116228 302228 433730 119780 473246 87590 548778 433656 614201 652803 199831 356742 166454 816116 686968 953580 298661 831241 970430 555233 702389 550309 339808 621773 229118 566250 275029 610564 635047 144072 257002 609380 699390 217233 179631 48234 811692 556347 285876 398915 123051 41212 980795 265475 687555 372003 426879 414035 192397
Output: 17897811

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Lamplighter and the Fixed Window Peak - MEDIUM Coding Problem | CodeTikki