CT55240

Last windows of Jeweler

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the marble forum of Argentium opens only for a perfect tally of windows. Jeweler 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 <= 2001; 0 <= a[i] <= 1000000.

Example 1:

Input: 1476 1128 303595 459843 542877 253745 434163 118693 112802 718005 943124 380777 360572 146216 881901 407474 12287 170217 550661 169872 547941 974033 462107 372025 671838 874449 149082 955745 576977 150201 388078 397793 685025 274520 388454 584132 356899 564171 200871 776448 287419 651333 166973 200903 172297 228028 639771 515424 237616 535128 703649 541447 931949 824130 261014 633164 69214 515997 7399 459191 1120 968453 914600 426769 370983 610500 647306 476778 526541 710956 290133 888977 828796 953406 666793 963152 354890 323754 990150 254893 2627 719429 745833 766587 737437 930038 901313 17980 327045 598032 743097 169074 188110 232261 90699 816245 498402 956961 150442 660249 313737 491819 230586 209931 873549 626426 41777 119703 13592 821815 688831 242440 718616 539886 359896 284046 1463…
Output: 562987224

Example 2:

Input: 371 180 824781 798602 792102 748045 205334 66715 62947 593857 250707 709221 570884 922771 238706 494795 560383 956228 966093 185783 17382 889560 633237 610055 442831 557325 235343 631405 115240 750530 980025 426743 31440 486433 779376 233613 388798 299781 288743 296768 35710 299826 503889 766632 287286 748316 842375 2370 915549 137202 410448 794769 844179 78585 746684 852411 343742 264336 363517 363577 424857 206171 768190 996216 778319 887565 473564 827943 549253 820170 469747 322223 673567 647547 598319 839630 76404 453816 457678 477460 902383 616919 62094 486292 396383 106416 404745 587777 644399 845610 418834 963351 94010 642838 652118 337405 827171 600395 568982 95445 902250 275441 827226 124370 18360 319689 232518 346980 765868 750457 425435 864372 612182 414946 264105 66749 100833 5…
Output: 92424305

Example 3:

Input: 1302 995 481810 900078 312385 45965 522504 679214 892952 488050 621256 822648 15380 608702 494950 837791 334306 536159 912584 930806 464142 293102 461873 784620 918666 64155 756864 192876 232770 339270 316092 472140 466169 605522 73913 518305 208938 774743 426862 901104 936982 267476 714083 790425 383929 560958 475055 962289 267305 163920 403868 991678 841203 171402 141791 388962 888844 181221 840353 778911 67255 466140 383099 808058 346756 890290 643405 542246 25664 386037 365167 948642 73762 40082 587547 777430 519848 193631 847903 550799 349489 720114 837715 100306 76146 378110 394892 693608 969892 930285 996284 952482 423577 855682 815268 194041 649286 350683 481924 982207 819633 192523 274916 312283 279286 280317 623744 676931 119484 972918 22723 552529 340381 239586 86721 742344 8858…
Output: 510092422

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last windows of Jeweler - MEDIUM Coding Problem | CodeTikki