CT42559

Notary's stretches Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the fen lights of Will-o-Wisp, Notary 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 <= 3136; 1 <= a[i] <= 1000000.

Example 1:

Input: 2763 2124 739810 322702 51876 918889 812369 630043 441757 511461 758791 250014 712135 200521 12128 128436 47905 177355 787639 526461 257489 376435 796252 427032 610408 380776 64407 366414 314827 52218 361835 581169 680878 328228 168420 937730 790076 601854 453538 457235 31565 549165 805289 75435 68635 365454 29210 219652 317838 594389 364279 458732 939629 455156 201036 392543 60408 789310 622893 582432 997709 284590 160735 453932 277603 952387 41855 59434 547703 410263 155859 292401 821975 837417 688968 883812 296377 502674 603631 614977 233488 943277 688564 156574 267893 250891 835538 386108 464143 817967 214170 924122 718109 885483 792369 632158 264231 395654 76673 567461 894201 8598 266075 127061 976806 433244 751671 447937 930564 255254 610314 545709 315904 22454 347297 578055 960294 9…
Output: 1069647512

Example 2:

Input: 72 26 617801 971752 131776 363644 23428 16099 922044 774256 489989 550021 708329 622696 332784 30288 726616 277210 992895 330167 757457 757224 948725 104250 764058 761038 21560 27740 634826 511408 485008 85347 181910 122626 292533 594656 288019 725755 303456 613723 707293 42698 407973 114251 343987 336984 944142 722039 467605 573045 512771 188892 793788 995779 586770 143080 630051 90780 507525 273922 634163 439485 382363 621020 86162 260285 641824 827110 647751 769271 932688 303201 2282 119023
Output: 14009295

Example 3:

Input: 435 403 585357 650357 741141 157410 102458 377228 79968 92047 253177 705936 363269 159139 864550 972645 537751 863024 189508 227455 922402 996940 745493 330491 161727 551549 220372 637466 923713 807799 535756 859729 486773 785620 859796 643177 162462 35693 815306 275735 100822 71250 603778 329343 306264 763895 999304 290150 565751 697637 380003 97207 525079 366181 333355 686076 386911 321353 483036 502467 275227 108164 773894 468192 607984 758320 845514 376403 413891 919911 908771 961958 354280 379705 665255 514611 232436 707301 732184 654612 850173 503667 997758 683970 451119 822678 556876 283282 786076 253302 939479 785775 275459 894134 431527 358065 845763 568123 602979 367948 582810 326932 694821 25096 804036 740626 864277 596331 266134 585004 560222 909485 101653 290508 156685 582774 …
Output: 209327266

Constraints:

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

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