CT47130

Kian and the Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the old quarter of Brasshaven, Kian 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 <= 2001; 1 <= a[i] <= 1000000000.

Example 1:

Input: 1953 1839 952631482 672644660 417482660 458056555 252216610 49836542 39261677 420901118 691372622 970826656 581710628 342652797 170061312 999238246 890918636 85387267 331100158 441483117 152275470 919147659 21217328 461954329 765656588 217645560 742560903 510349348 412803281 172755390 644256967 674159751 17024439 965761248 817872042 91432965 889592891 883421423 265807900 382177629 199890027 64559505 883466080 163417072 685064090 280547493 930417576 237397800 892476264 47374564 991933240 340619604 560725212 927510299 720323706 489478589 128112754 227555185 405164178 383298703 585193061 594484407 460967703 939284400 974704881 924990180 789988645 843283616 131415975 164222550 380875958 982152833 775908458 402783470 636015698 183489573 533011016 780473181 799075640 722820999 927662549 53126728…
Output: 935936907027

Example 2:

Input: 856 701 711359635 258713545 389666322 471640850 453491883 67522618 717215810 548574094 868306783 291115931 436159191 129667787 452644002 348224729 79545659 937622171 155460430 701605458 829415358 466710276 876032895 98842935 540219893 55875127 213034035 257585049 679868719 774207590 537313677 365308003 234578087 203983855 15519642 712259208 381931035 877183584 561214765 257789982 582276674 520091542 147275625 435137756 316945962 301114842 911975748 211374224 185016505 315871825 364271486 801044415 53090715 679437007 859222704 693582626 962604093 722191773 499763424 784429240 135506007 302023169 142314104 512601612 254501563 972722241 719989492 649454460 145823683 417642010 448568467 652952867 794716842 772966954 598656922 714701407 30261837 871508740 874993492 501132196 215549934 2155528 6…
Output: 354740206285

Example 3:

Input: 1958 1320 617530314 996575921 948787218 467351972 25381640 106505941 694210623 829560251 676405342 81677517 205440207 490676744 369877247 364477973 253610403 667809659 982165338 870952416 663557542 758873497 300282434 47171808 993742021 315756384 881369367 31658453 354198620 990461665 86280042 830212623 250940701 944449156 833281079 822838170 820424217 63533745 655048328 150215708 378971485 307608509 182598484 65547135 853977934 82413265 346662909 768738550 999380768 769386169 682116761 253612896 780276995 114600206 458630807 117080219 253673641 414977451 529193632 524065236 589485148 445160229 485869686 528184845 279637361 303744718 170156934 205509550 576594667 368655006 519350643 356042362 849245270 106662408 909137547 637659521 599976723 768174869 712176098 752204708 335860702 68089020…
Output: 665729298437

Constraints:

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

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