CT50132

The Fixed Window Peak at Scrollkeep

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the archive halls of Scrollkeep; Corwin weighs the day's ribbons manifests and starts the calculations. 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 <= 1354; 0 <= a[i] <= 1000000.

Example 1:

Input: 666 418 402364 550770 48465 61545 777 459898 369113 215215 916099 84441 145715 804568 184872 35765 158551 22275 352213 220413 899034 885887 117599 261988 899705 502019 805600 473853 481708 66958 945289 147212 632508 826655 50683 554015 604906 802456 787150 616275 414572 923407 157918 44444 278891 841648 952542 535433 260068 362140 798028 665757 405807 284644 397683 252512 781094 422052 69123 16169 594693 22312 587140 255032 719490 160755 668939 418412 724258 382439 432740 69152 311901 217786 337108 545651 758439 735145 349692 64140 839300 139908 128344 934005 60394 901329 529997 263740 151731 887801 941579 741983 389083 928878 51142 931230 317007 962258 283387 338855 124215 977313 873155 883297 662159 786792 107469 868303 70935 455041 833062 904868 774807 548415 978424 142114 315707 570640…
Output: 217038563

Example 2:

Input: 1069 333 633559 756732 711769 815511 600275 77012 910387 683539 8950 685859 156140 263372 928213 391157 201882 740042 794314 544348 802925 659106 884637 169462 465013 692593 800168 582786 402206 58501 54563 693501 286000 995393 735397 580722 401487 625964 375845 917198 740356 401523 985979 675952 128199 70564 536908 491740 442044 456546 677204 938664 958346 233675 332740 35520 418825 222570 767074 710718 641055 710611 899309 243270 214475 192071 648877 823962 220720 127831 784506 428739 406571 864448 638821 896836 62503 588824 774463 775211 668177 935734 255946 715914 972043 737763 162669 40326 376275 365474 173262 595495 776177 327634 346136 752171 659919 948647 532364 666407 973984 223829 433253 28260 486314 408049 468178 514886 939434 358498 371266 96406 16296 418128 146778 125568 28234…
Output: 176193736

Example 3:

Input: 1326 960 56745 101053 350641 441536 944181 264965 477387 538280 540486 841169 280317 845670 346294 696700 274497 977091 559396 873072 11561 508753 449790 381603 891653 287000 845660 379503 22431 205243 936967 314031 944369 711258 310594 871603 290213 582333 887313 472364 520165 754183 283885 802612 744337 687929 110110 241820 442689 657430 939088 288468 712406 806219 810502 588527 688335 365802 952057 730072 991042 975975 471285 821444 987420 788052 745243 820636 513833 491365 504401 357079 131193 566421 403498 968262 164227 458351 607111 7374 550858 49104 169033 960239 672695 388770 777102 223286 730403 264180 73701 814362 166784 248285 387797 319924 897042 897282 429455 266897 501794 886690 412050 954661 256656 161138 921597 231216 856719 402897 376152 38687 385441 108687 404923 924499 3…
Output: 471730777

Constraints:

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

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