CT33216

The Fixed Window Peak at Shimmerdeep

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the opal reefs of Shimmerdeep with crates of scrolls, and Maya the assayer must account for every last one. 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 <= 2783; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1496 347 601005339 924842544 562832854 246876000 319758025 814609519 752163073 547360768 82778028 822757491 498231793 145372781 730327497 639697441 41433064 816696583 909562801 955005550 843074352 922300425 499767460 673089473 23848758 243156084 643549219 317822350 382783782 118288058 765630459 52941506 357414799 491280451 8129193 760264272 737663118 539967866 120956110 760477796 134105297 544096356 247797298 333909596 611014602 16676978 113937826 782628106 87655344 644560577 117051138 697519509 820272723 347343164 626705897 81210099 712689117 230290840 192755628 765735697 638181367 214171651 463774206 871430839 109723964 607321561 171709165 912022478 47234863 124928078 599530847 736358778 300354081 359805492 463878922 635708594 604705102 350460971 736039694 267988551 337863995 561939279 8…
Output: 178574149454

Example 2:

Input: 1478 267 950764314 171495188 866801833 624885028 661068419 813297378 242258493 732417726 668533922 605424861 409877368 587374660 139637092 445946350 817533950 17766696 594996255 793004981 616762871 458743748 648984988 95822221 236191036 822929275 813869744 212126570 452590068 899915305 691220749 751926136 8097622 204601025 202536878 128984893 156990547 448441770 922965058 413675263 386893207 829980625 31797239 994555784 643980717 73566821 236490753 447642354 889795713 654856877 760017164 602929859 421111259 223957623 244208151 834134806 835117445 60826343 199253794 548719480 891322964 758283937 30472401 294149539 432368492 485296514 116380332 587906086 151045681 806732843 285522017 472253524 360290692 596029149 252383301 38540349 998527225 374101439 330076650 517283474 117835779 96181054 9…
Output: 141951258751

Example 3:

Input: 701 208 978858275 569881576 4049771 306600885 367454273 486845549 992368179 599873170 420068082 42396692 636449845 898127741 151411203 290762045 676931937 740181583 699171231 438099459 189290729 621817914 246199751 566550216 969780596 712754615 230932431 449592832 930351824 856280790 761274905 27785839 614242796 743694876 34488318 871277122 125389763 683002323 797414174 972062154 241316827 494721566 402074476 465171234 334241020 77566107 375197409 867191685 961699043 459432725 37876091 61971715 422975541 781844032 24595034 263793427 825609144 965775634 760365936 483326504 749552558 82507790 252174454 926204351 673883298 923741060 346219400 921515126 261192674 149454402 609753674 80867017 220731872 563134106 187905067 255945410 605289416 81107689 65505198 210659518 67124445 672292637 171899…
Output: 107786898106

Constraints:

1 <= k <= n <= 2783; 0 <= a[i] <= 1000000000.

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