CT44839

The Fixed Window Peak Beneath Scriptoria

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the ink district of Scriptoria, someone must forecast next month's demand. This year the task falls to Arjun, armed only with the ribbons register. 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 <= 3011; 1 <= a[i] <= 1000000.

Example 1:

Input: 733 711 909919 624082 739066 848494 354337 262357 723405 419941 371894 890977 256623 505575 101313 409693 769117 920972 742224 119701 418792 721246 912402 708888 453233 674545 670340 101029 208792 72284 35149 48175 313405 418189 874938 246345 172698 753443 916773 809694 816552 448617 748062 715929 704767 770564 885316 628519 969012 815327 755272 739208 413840 661952 218416 610133 693288 611528 889723 829025 129055 743498 410919 444664 756799 646554 974193 289430 246811 952277 256923 221081 589024 832871 47229 923773 789613 319759 909602 758992 398175 801671 242485 645336 425955 134991 303574 85486 565167 866742 457540 122638 654844 506802 154348 276616 527816 691685 53428 219364 28820 421655 107043 820281 625480 525770 54849 298601 890141 565812 702811 244383 365200 877204 964687 65947 944…
Output: 352931991

Example 2:

Input: 1295 1168 87558 105681 117982 842828 76939 971866 784166 392060 29989 665363 855825 780530 101356 914978 805825 650090 149543 50502 201246 610042 319068 546996 886815 210183 527063 189105 429429 137589 416427 983917 556184 498010 136597 817308 324711 386274 420967 262928 446202 58511 633490 598139 404858 898717 568684 940378 869233 430069 770467 813573 759143 898105 811236 107363 920832 58966 253622 438310 577090 677146 784382 715262 892663 369191 134266 315989 662000 729069 901623 474211 610547 893106 450286 602925 382549 944170 248269 161063 327616 5587 977087 261279 541786 973099 484133 545418 342457 321646 391973 569844 1663 693059 645386 424523 589215 534021 929695 339599 491852 142108 790170 508516 687367 459359 529451 640526 257606 259782 686935 246787 323879 522950 452789 814901 29…
Output: 582567416

Example 3:

Input: 1796 1222 259143 478365 100923 579488 600341 938085 518805 427450 839895 758600 184689 467628 125702 903522 813720 872907 975518 738325 725147 926366 635280 781855 468515 496011 867672 160215 777024 111635 591428 237823 308346 691404 490914 680181 821590 91230 112517 544085 979753 862421 853404 917756 324497 553310 657221 932266 510636 119644 154350 543537 218480 11471 976161 585898 923193 126739 175451 619511 665914 961110 505830 884928 584311 672855 303284 760901 545386 606027 995772 289696 140703 800670 843928 913824 41733 24155 143281 756399 516097 375611 840863 698488 668919 786179 307645 100067 890169 230358 926227 133017 175039 395388 160938 320143 636727 829662 814152 446171 128669 573970 60691 692527 701021 139559 691080 272241 380560 640016 108460 468347 701786 385194 823887 5446…
Output: 637809541

Constraints:

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

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