CT34538

Amara Counts the ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the willow walks of Reedmarsh, Amara studies rows of ribbons entries. One clean number will settle the guild's oldest argument. 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 <= 3918; 0 <= a[i] <= 1000000.

Example 1:

Input: 2312 1232 749328 386314 113105 595561 118646 176482 576636 193143 786160 749968 65654 816417 157279 921768 350361 32891 309766 494004 755056 668802 671306 781477 441501 202045 111508 818630 513009 335709 485316 755108 385346 680123 150814 783894 232220 312609 924927 913465 456096 271561 747767 15163 212559 33850 316872 982674 957631 881156 958705 264014 118536 839085 302789 163297 228725 983769 846898 200058 93112 900516 373868 476831 895383 349586 680025 956474 138579 876706 672891 285293 593432 448894 402624 524040 480504 732828 389113 266759 367554 528563 923429 887719 110322 665465 129396 624735 444227 339997 779275 991513 57559 146020 569115 149178 53034 782000 682589 583439 962192 839280 586949 72750 343230 347914 195942 60064 970540 115635 10626 463023 698145 365385 859368 896382 86…
Output: 622898850

Example 2:

Input: 2400 206 110257 708317 755687 774827 295642 306577 331460 346102 708871 63133 514750 451123 421436 107132 185087 495440 266001 780253 676773 776956 569000 516966 519603 838609 677305 55374 405512 225430 186865 742173 405848 409838 449976 181330 518893 56832 680652 147651 695263 808863 974590 287333 667737 607504 332959 678083 725821 922251 651227 515178 344601 732687 822051 200434 626888 589919 768927 850956 54518 960837 851125 857700 755708 351313 312100 386003 272960 949624 417264 444228 594978 919280 791709 610832 964955 810197 202988 990323 942439 56358 830723 628227 499259 215613 527836 772805 397723 385625 828937 223493 790589 224201 909554 260444 905381 922515 868587 857534 362634 230115 750395 312111 231492 965989 408995 969489 590143 922843 123921 389199 127474 496375 288364 10661…
Output: 113740727

Example 3:

Input: 2871 683 933522 749449 140141 98221 953513 241620 723126 680257 231503 609852 650584 866831 658690 2108 619747 279831 351013 337308 938174 793048 532131 525704 66783 661047 176336 460500 976927 61212 330363 773892 16619 507071 596905 411351 865329 64408 738710 107880 283890 607601 310944 234204 49511 281421 145962 365708 840506 738900 901519 837824 337437 308830 394146 776969 816254 524608 509737 983223 933170 854799 272818 966672 520296 696027 252718 870731 582820 389819 584213 837784 996351 275462 905338 662810 208091 936416 672263 55401 545358 510495 373539 617378 802074 255675 231336 543859 734613 145756 615737 404698 630933 43469 859685 381867 186236 487606 909615 333165 221009 30767 587633 921631 739514 932210 331326 790339 159094 499915 719016 795985 936005 677060 646411 911953 1999…
Output: 354688024

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Amara Counts the ribbons - MEDIUM Coding Problem | CodeTikki