CT41276

Jaya's Wistful Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Jaya inherited the ropewalk at the mushroom groves of Fungaldeep along with its curious bookkeeping system for scrolls. Time to make sense of it. 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 <= 2391; 1 <= a[i] <= 1000000000.

Example 1:

Input: 603 525 475212242 329063466 445576664 83367366 903067327 60860414 182139461 984669421 41016745 916954113 123796073 789904193 438435967 245112628 761111803 723076285 641684428 381414153 845163652 467757081 672565661 385773722 580119080 27110008 443993818 535090340 343334399 58830779 721799833 767812535 446798073 461672319 376013703 920816580 594772310 987504657 198605523 696023523 321653659 782768626 753516384 571777304 913474226 358840402 20093403 684310999 671022770 807686515 932508835 233210750 333919091 336622153 955091225 546085081 672925327 17255550 263833056 989840951 689956411 430945355 904026189 69456890 663748902 696884597 597270174 574182770 807597377 271351322 987627083 353218661 887277974 276055888 683418956 113163531 399313027 618761819 36971799 594384573 19333888 834941118 21…
Output: 259407298853

Example 2:

Input: 873 125 560191088 28093513 769608418 825002253 419316572 695825857 835551016 582986756 158568633 994343649 802712567 55765342 541990896 322904817 197195127 150246074 226773190 981131304 216950740 331926602 394570666 560579849 155901629 923840069 26250100 330405877 186474531 362093479 418187211 411099378 455425954 793968446 585622172 636627051 624779032 711745605 133798843 297686191 414081818 218846550 826390906 996232473 71347653 226003052 149310918 88126445 551725615 228685443 459858016 579568230 784077799 841909179 679055454 978171257 892399599 311157196 307724239 660339251 882732501 361857169 200304280 81722149 966227544 969219305 65608979 967311160 447316079 480562638 810099199 933876894 966000272 428185054 561133963 951744741 163580485 57166635 52554742 19757569 480945918 275187700 72…
Output: 67419242913

Example 3:

Input: 1781 1169 31847598 442439312 921540682 319033190 747666182 81755835 882862606 830392818 830867537 337116442 782804279 156571334 942159630 519237430 465536522 706306425 923599314 879062612 63275568 387640183 335823383 682725425 146166883 728655603 693148163 658556989 174209397 251891267 343640567 855620005 977185197 920100577 362725789 943506724 239948096 375699532 290480719 823804014 272181484 729964811 820209974 656754514 876155916 512665574 166241464 951379022 535179129 808776884 61908484 171721627 624012208 551601175 242930468 63370219 361790969 183633238 183389288 230021162 407668654 504754291 61763799 824990958 916851030 648955498 396878121 790450106 306251852 969465781 410555055 625900135 189562361 641755455 241598555 387584029 155198821 808905400 40937736 331443085 598695255 9877916…
Output: 603069940332

Constraints:

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

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