CT32712

The scrolls at Bloomglass

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the orchid house of Bloomglass opens only for a perfect tally of scrolls. Paige means to find out. 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 <= 3139; 1 <= a[i] <= 1000000000.

Example 1:

Input: 730 17 311764623 457041030 805343030 614332787 711926927 289732187 747652910 425934093 714623702 685065589 448954538 919706216 443216691 295660085 374433864 254155845 107115130 461234834 147143330 995745915 458851963 574749043 81818276 738694267 680579962 373163457 311224361 737479504 622634652 342752536 393560832 725149550 787577837 636473665 601875321 37589453 401053690 817415963 283668131 591542807 79429644 698216128 426931565 608823723 196279723 468352079 752984337 889189656 973652921 826569727 612668224 375949252 818139730 233996602 254229164 723214607 48333904 540242190 988078502 485407623 568596791 640883151 571389649 325934917 127943931 971164456 372865924 375786764 96951836 671761608 101976288 501181361 3708302 418608307 269528837 228066192 711706932 61177125 428845424 132535906 9…
Output: 12298654825

Example 2:

Input: 688 239 180233766 246378008 223090459 950407843 857849104 912309445 451922529 145941489 384206253 719499831 758921731 102672239 345859511 563497079 989280394 391552880 661235359 690260219 451828972 669579834 556690128 915443214 271377435 592371337 30406804 585115754 682925704 848228565 745455837 232231325 194471912 245001299 646710493 284876870 255606726 39684922 866757963 566644895 656273591 1326100 887531508 106633105 864531777 306217825 552588242 82058525 344616089 498541163 21319982 498868640 106958705 910786882 469751691 516956461 161625342 246255316 748366121 756875732 818022417 852422339 53845412 195945759 558005780 445630847 26357153 51135383 504522439 595026285 788869421 266953452 495123183 418699 1775550 314952912 971972711 310665798 728364316 557687232 64705222 605606181 5112050…
Output: 123099900979

Example 3:

Input: 1740 365 449350253 414943782 887964703 384832196 817247051 498162432 224319381 362549698 360099592 687216501 557455660 924403507 796953905 973789099 603468751 413228774 507490210 457681767 652781568 505492929 323624982 546808624 851830558 964188595 630995439 995214790 623473597 4220928 233943068 740838717 962815486 290092779 987014619 664873889 191109730 573959003 704560439 917729737 761439060 596582009 449189369 62256467 213279983 309416764 59368110 114643331 640084968 336162068 386284181 965658076 428593975 594142380 560710509 466514537 548750461 829242180 594794653 866895251 878345960 996317330 128961298 93618546 835669926 618182847 105837074 855075828 890770225 613957620 464454087 191397506 13527959 284550512 195914574 763533006 705243361 67081049 507152244 56588353 17764706 718215604 …
Output: 199076912926

Constraints:

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

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