CT51389

Last ribbons of Xara

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the ivy courts of Vineward. Xara spreads the ribbons records across the table and picks up a sharp pencil. 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 <= 1360; 1 <= a[i] <= 1000000.

Example 1:

Input: 359 83 63696 90012 176027 573817 113902 794685 379558 106298 507674 192000 640666 391579 975504 772189 430295 386128 828751 493548 917351 371452 998471 183311 883291 229469 802174 665712 297772 642870 297118 310617 370479 977484 286251 472306 245399 572877 57298 279582 882375 24785 699590 756584 353977 214618 502683 154155 609686 488309 282303 407157 942906 773132 838041 376628 95347 725584 345421 254943 683592 75093 282785 15729 135262 760905 166791 207596 931483 651255 343555 964092 455114 95588 150850 868346 565431 766021 746993 961599 999975 454221 175550 359355 531476 663749 798209 959904 374634 989900 851940 206710 422679 151261 223977 76528 519056 504252 886486 195616 179168 962561 757531 278171 108389 598264 830466 928940 175903 543925 441096 849459 513640 332403 464027 555535 2436…
Output: 47073551

Example 2:

Input: 457 251 390870 959632 995547 657560 377969 750611 256289 17265 82808 277291 528177 160064 981733 347704 549378 104077 610018 275951 234326 962042 963979 325839 946850 141015 334199 128105 945611 255459 149522 704304 32212 846545 361773 26601 535354 136882 853914 706744 576757 67478 646320 689414 213660 395274 888493 889635 54274 394162 978867 35467 907447 979099 181704 55227 450697 932069 732904 556362 930748 913766 687194 92989 991406 471883 282568 793133 884489 732608 542657 652750 192641 745391 116828 326691 597695 836420 628698 575982 533990 235083 36144 306534 106323 474538 968991 759082 263724 127784 903402 389070 17502 817438 919434 42215 547351 383531 669264 443348 877027 235198 629503 473011 717142 138017 412062 681115 121675 4198 553685 236168 943316 397337 33967 157553 971595 86…
Output: 133959771

Example 3:

Input: 54 25 180828 90724 476343 730521 247032 481043 404206 735804 699878 739193 729525 853750 486640 622922 632068 941903 247365 964646 461064 23436 529557 999231 26056 460750 930618 677452 204276 346750 791918 736976 482163 302837 515416 682497 801190 62152 852236 982944 16706 292580 315661 315588 52452 276929 763501 211135 241224 262617 391664 71694 609441 469156 268676 546611
Output: 14728147

Constraints:

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

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