CT54626

The Crystal segments of Chavi

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Chavi the assayer watches over the smokehouses of Brineport's stores of segments. A careful computation stands between order and chaos. 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 <= 2033; 1 <= a[i] <= 1000000.

Example 1:

Input: 787 413 584859 332810 941708 186320 579953 509193 208988 463981 200201 283364 113040 710284 328922 924251 367101 36623 193439 160800 735891 149489 601434 202660 276451 738476 571427 729859 219383 239542 577801 811788 971307 659816 858990 699788 364303 652685 307588 621312 347830 560787 547980 313346 401014 324257 930839 704818 219527 381173 317058 159656 822488 553998 470109 360534 418867 173702 855454 505521 980431 872836 22931 26805 463959 13892 903657 269072 567634 596161 714227 852054 349300 168219 211881 665693 132238 448673 777777 519264 844749 392184 745743 433613 721178 519438 261902 584613 317122 101099 189888 998717 675579 21407 98961 914818 555400 871140 949037 917301 624211 736217 749371 232921 720930 908208 20293 111121 222174 198412 430576 260566 585255 823784 815881 112838 4…
Output: 221053816

Example 2:

Input: 1036 746 955108 296042 894663 151075 263348 67956 250106 221906 681 846484 479862 155508 80827 21302 771459 919653 692571 221497 696962 438200 746529 85465 455252 888118 441566 840142 609051 243119 210547 428045 116485 830637 854334 78600 7552 925252 3533 413784 864614 745371 157183 466111 515368 29671 304907 207199 954839 121559 300433 771617 504126 57799 216462 313190 482115 627312 779029 3649 899350 69806 742786 223584 108779 643774 321023 846731 71730 991134 873942 363113 169477 255253 50094 75167 486567 328553 601512 188297 262133 305648 501042 16862 387538 264488 259865 348935 221236 653621 802499 713608 587504 141592 944861 868062 824914 274691 696586 179533 692951 664949 393137 959281 607092 670150 130526 135612 160518 544690 153183 99007 72014 944989 763662 339095 936438 347899 65…
Output: 385935096

Example 3:

Input: 317 160 296357 259804 183548 914092 565109 65958 94451 790417 588646 940989 244163 412345 842805 656060 283679 647483 189041 517586 619578 742314 724985 426744 729313 629660 659228 625514 503209 980175 267077 351164 536616 770897 686511 969368 396653 325056 950997 393869 802998 867260 477740 879514 649912 730888 77554 199323 227999 518765 895508 3107 653360 113294 714592 142624 908723 13608 763310 7859 901704 355004 637545 492775 97868 942174 554802 552306 486547 318318 954714 645877 181961 115647 92055 59103 706274 516580 498186 520553 169562 801595 423068 910606 659241 805906 477377 918947 518854 953896 870010 911501 867874 656274 88557 988346 435832 127992 658987 425583 122103 235089 802291 7542 816228 392565 687616 829399 390742 18916 890143 697181 351213 225506 651754 854134 779593 97…
Output: 85466880

Constraints:

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

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