CT36010

The Fixed Window Peak Beneath Verdigris

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the copper works of Verdigris, Iker studies rows of scrolls entries. One clean number will settle the guild's oldest argument. 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 <= 3205; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 2198 1854 799944147 993133447 257832662 286558932 740098396 650347391 222949711 635051785 282114518 875752586 369912243 793080166 585109577 638029678 152710705 747974459 206005855 263249443 223701145 96161325 616518499 924634309 528540241 436398878 987536469 145546191 723100275 705607615 647521105 602912693 932916645 685339833 151750501 467456722 103063873 878370944 649008435 387898930 373857571 682645059 157038317 424720737 601167404 520446371 410129279 322306539 520360426 883671918 223742175 652071689 2125 624933241 59882953 92751554 552416106 227184218 203432512 715896493 370977280 967613941 780475011 770237533 496102814 537028977 835626880 735233098 18791530 660380768 189078369 580500356 102787326 469181579 69038951 504133196 471268447 508457890 374881819 252115601 839391608 350947906 …
Output: 945692826894

Example 2:

Input: 3169 85 868574558 718831841 649684767 66754282 226845290 323169082 843132319 223025506 2538070 493759634 803021301 206991706 189923471 383852658 596485317 641966481 316682546 705935046 968929943 341693131 294509941 750500132 994875569 770480010 470069362 783192518 237861483 409153094 662879124 98226101 294853879 434781360 392701780 77580257 838624033 81396397 876648723 794144175 21431352 913344253 159011930 656789909 903248664 714039238 966004535 141613975 345743772 621485467 157258651 692130494 223507612 221926016 451302654 388533479 417852578 95198162 71858626 371903666 697443982 273634927 631848311 460517571 129134114 624857722 789665919 381246765 587240888 698246766 658035228 164936686 611963449 953340341 870785660 541120275 737172785 930457774 680593375 235582525 23750328 993886347 48…
Output: 49215291009

Example 3:

Input: 3073 311 797647937 275762901 651070417 956736838 683618119 339423659 100662022 90386514 3032495 481464994 337508278 998321783 391953626 597230945 853099395 44904726 567268373 722853058 245564424 33417667 77662096 157230699 754094243 112176896 870893647 196638387 442811064 880318434 594976234 622218104 404302030 675635135 764946871 98601625 497704971 333698612 432025539 989772671 823911454 895629856 477602460 420827266 385790920 367623870 348946435 659929128 706689288 442953541 717525833 502816067 572747575 517836041 767045585 181253409 155273614 461010061 580846684 426172803 950536623 3221998 378186190 786987306 661090168 590173749 119978468 748699857 47677273 217759614 613834038 305838944 765639891 4637902 934297806 604139968 985737091 157871441 114209893 584382698 452046919 717742811 480…
Output: 169512769823

Constraints:

1 <= k <= n <= 3205; -1000000 <= a[i] <= 1000000000.

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