CT37206

Yusuf and the Bright ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the quartz ridge of Glimmerfell, Yusuf 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 <= 3285; 0 <= a[i] <= 1000000.

Example 1:

Input: 1338 1259 703130 559254 874473 928391 252565 275237 595925 969308 380321 291335 883360 423581 107919 937936 89686 78506 159980 790118 567209 720350 222322 72541 313138 836799 701099 670412 364600 960464 557937 834305 611488 392907 827121 378405 571238 54743 345128 138014 681764 28062 921831 778195 54115 480944 725849 259360 421475 7364 870476 650753 420137 404346 612183 734717 937508 750419 335595 15677 879482 527807 632758 904685 980176 736842 846697 651219 527811 157631 49367 766813 419962 618644 558795 712767 880432 624878 117238 593875 354008 235966 558554 753354 877287 936704 141009 472675 214517 281979 721403 735621 778309 511532 657776 77675 426827 857579 414056 258215 552867 346665 315167 867612 421062 159667 66326 801384 84096 737732 599744 11554 892488 415295 482273 267158 737139…
Output: 614895922

Example 2:

Input: 228 66 383265 603626 146845 879154 241804 882340 28827 140146 878250 221589 757792 784221 682785 939156 202391 521346 87045 849532 792490 975149 387387 288052 66961 161733 177766 930672 716231 772592 235366 459483 929317 389396 760819 20468 302832 945998 827616 40151 100073 650750 797020 957552 628120 786064 201501 553556 538003 585066 952216 537992 102091 877366 855501 169269 204013 846137 277472 272855 963596 379646 367029 875221 90962 720728 302915 137663 808480 514501 851102 93913 153853 997127 728346 591261 743393 961446 533349 619965 859405 907318 924285 881648 936473 271963 884496 973402 711889 862049 882836 173894 468086 885885 35732 354608 572518 544808 714982 319967 715608 474433 513903 912624 262012 379583 463345 336947 111900 631764 316175 143398 152549 410984 864667 740662 566…
Output: 39395798

Example 3:

Input: 2055 623 272533 239617 327672 299645 486772 524655 211612 772406 633583 574136 64793 571125 314510 691654 702615 303530 911887 578103 903852 76779 739471 17030 703061 344978 660158 680941 186038 756453 142680 60451 343314 361165 232423 936933 756600 976200 604637 464018 228924 135633 996852 30373 469848 871387 408433 241300 80776 644242 969505 409701 229711 966821 497135 954119 623565 748646 317736 149166 648379 429941 485471 356368 139561 118533 991345 986701 909424 747914 993554 719251 256024 316317 485075 207536 916343 210397 992468 344647 178839 601455 219705 642309 825017 928186 606468 164801 275099 953740 776677 238614 708794 900969 174948 310999 503248 834088 751867 266525 212388 640947 985588 913286 667567 191787 953493 103876 819868 880660 46513 584892 239508 927555 852994 279019 …
Output: 323358570

Constraints:

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

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