CT30867

Last stretches of Zane

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the wren hedges of Thimblewick, Zane records each stretches in a worn leather ledger. The guild wants answers, not guesses. 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 <= 2268; 1 <= a[i] <= 1000000.

Example 1:

Input: 970 427 705394 331617 591273 308866 833792 295251 842375 545652 509010 506166 528325 99373 162037 727783 386381 402923 142565 411895 274072 79030 537109 875185 527890 956139 385603 666095 854487 491650 532410 705949 533558 155129 911324 545317 149194 444918 165977 366962 316238 404977 510496 291804 520208 395384 115377 955604 349543 289157 905794 273519 385529 69145 688998 809492 912583 635179 536074 630462 89046 57509 735216 310504 243343 468723 85784 492631 424193 879590 179347 905490 178490 938581 513178 783787 804263 633376 20420 878527 391548 59926 497101 582253 345166 198318 220849 871427 730262 485541 835851 378098 375549 117723 581096 610372 248299 925439 944798 757838 702807 486526 447402 552651 806058 105369 81699 667194 871905 1629 307435 579989 451887 559846 215813 122226 44706…
Output: 227379681

Example 2:

Input: 914 787 582458 864817 388346 738195 438439 13021 358807 333529 999154 803532 393800 987016 649319 200902 647303 890111 276228 484881 860052 298053 503197 588749 438454 501952 952367 387504 586648 374330 200851 539489 386125 890206 26965 543835 694441 206291 884013 85998 20602 930370 259622 536254 62102 634489 782683 914762 38292 442024 294530 523957 777635 890709 100938 689055 652836 495209 764799 935028 158670 622318 626291 938295 83742 518270 84757 674764 979993 133808 43213 403728 752365 871638 809798 616599 864510 295600 364914 451882 697744 48087 92040 603786 778028 137755 482154 197321 274930 926200 994720 657772 150779 299884 383464 222810 584568 754432 453086 279159 7236 729956 414204 389719 248203 561866 519430 383495 485251 528869 346328 831643 484291 710214 604118 453497 81899 9…
Output: 393493453

Example 3:

Input: 966 662 441024 466337 138229 738750 317413 494063 675853 681544 55916 452332 603306 242443 575996 860920 138546 552025 738552 645888 285838 282389 583388 95402 812285 43472 573545 984883 779545 403672 628270 492286 900513 429449 226071 427888 534302 984482 623334 988922 211019 655284 191436 894762 975864 369244 626792 80473 727778 754642 982006 748393 557770 317002 235069 729564 31111 111684 423384 79588 90824 550532 190085 848039 231432 59534 93834 807826 368190 308840 949176 804599 199117 80803 192670 566235 759517 754838 363475 51628 894346 149832 138551 99294 348690 34979 970777 416927 415542 116878 332621 221340 56806 64583 932620 340020 149785 972448 482828 37608 488044 356487 704643 657505 525680 668214 312390 407540 118487 482731 66254 493013 428659 379356 433775 720132 971939 3098…
Output: 333025134

Constraints:

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

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