CT32586

The Fixed Window Peak Beneath Saprun

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Zane runs the cooperage at the maple sugarbush of Saprun. Today the books show a list of stretches, and the numbers must be worked out before sundown. 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 <= 2099; 1 <= a[i] <= 1000000000.

Example 1:

Input: 2010 1447 971412136 130369186 444040913 606344790 634042338 357083827 506169353 617056430 566711717 172319799 949353715 696638332 881596795 375718097 473350798 943843180 822951221 818031631 75804777 614072276 472353777 937501036 831523117 124826069 756479628 902367014 666426492 772064076 528441200 634651905 444965901 615192309 689155132 248829467 100141158 678519984 55712060 680901947 9240427 902811983 885977540 328164948 223262953 619128757 380437068 574250764 237032887 625678390 686237379 28164015 395916985 416061283 375938188 610281682 426453142 217222173 881093523 943875069 606399524 85001316 102671063 502859611 209198575 184798517 196596181 105146193 532458665 768801845 693753043 665600440 237925855 357692852 451484030 579985271 706297960 18165639 780746799 35026094 544815817 97605856…
Output: 746598526773

Example 2:

Input: 2009 387 79575505 578787039 243327494 686586944 268217311 565768069 291081714 593733757 981109781 918528470 469341377 391768700 942125357 853249054 232408247 110017377 596236720 170972650 780216968 60075810 449014025 460580514 914638720 556967936 300584372 563336853 339483934 373315436 471935805 631308669 339614876 346862031 566825940 343705445 164149814 163248473 632237614 255222500 986320364 732375041 362684860 941442718 722644770 551486935 1586628 201984300 107217791 783209116 113667090 505587270 285030808 700123718 826360798 758527294 967740496 863821327 540630209 780517171 446263050 514192179 699474254 664889065 52931724 369380640 124575296 434566375 647687481 522737575 425226371 663073251 922794410 574612015 549682554 580125882 592457867 658482971 767895504 165569734 144603687 117697…
Output: 196074503378

Example 3:

Input: 775 356 672693019 281947397 713249486 183771932 467668309 200746921 878838556 902613096 9998912 496963760 69269177 11954941 717273696 598900276 531728040 236990592 102460535 522329341 785686330 479431201 702033603 419377460 723961644 723750303 657668660 397018446 672653122 889070077 364427987 7476951 994089287 310053601 25219923 940004158 877009947 397066456 216743568 49325931 496372037 478055606 92105712 846544653 482517540 837226134 969713904 340036778 467134221 871788124 627254860 762902486 339438087 259931437 538734095 138878509 701557430 995377004 817007672 746568213 357310423 825285775 427541680 150325147 970144377 255087022 203200107 160289362 699540313 712423187 631236046 10269377 453700137 816872104 979803711 910362649 656629658 781465035 615220808 987042294 12676623 202855363 756…
Output: 185415269106

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.