CT48710

Navigator and the Vermilion ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the alabaster quarry of Whitestone, Navigator records each ribbons in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1561; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1078 800 990550660 556059481 986973485 885700236 760274283 751710681 119706260 52105055 936226844 551002769 90135892 490448869 595806910 30550124 54531374 507411419 602815676 977919020 892277912 912023025 728198087 -842769 333259072 817059402 272235511 264130200 954454759 367417638 163760927 32820730 824102350 753100967 49367250 92888301 162909989 293213365 376999865 218189301 267704081 558232018 261481757 893903802 616389305 907525847 165562826 960865575 418655001 912271584 772763065 118657028 476790428 901981516 831780582 143559013 576797966 260000094 980348360 931747597 420595087 574623001 87148175 175892355 599576423 602426341 314715630 137526643 168622897 610196375 921039004 975024364 21949732 925744037 858896166 834532467 703228923 506719448 928237842 678082276 376520278 44884 355602…
Output: 399000726232

Example 2:

Input: 427 289 711053071 291191293 982216492 969974338 356595732 672621036 823598177 985395748 952254194 459710650 44563954 316581920 437633616 996286720 892461611 977625638 581026370 222934862 817726986 223632725 244120967 410261122 921914339 188473724 380542602 903062623 300946354 462807844 413260992 390862625 25989207 492707532 742244450 198459949 789612529 646388331 302901636 461566898 337132288 158943080 545381528 940148638 608299108 733035484 622993347 561764879 46695628 209713511 667207037 652348878 949946428 825762526 704709622 484454488 656106397 972588454 559423336 824349432 740727727 500145591 704857705 587710924 947449861 310663656 992846871 922462402 98832407 343184841 597962614 313162544 617783151 927487543 116021990 549446923 435227971 427875797 918292410 642003162 494158521 904047…
Output: 151479025264

Example 3:

Input: 1504 134 894146844 414185288 803561458 246416510 333065507 982009151 443440757 471799469 332697181 69492019 507847748 259962234 437430398 506765966 416215388 472084949 487933646 382492071 961222829 252930714 549401669 826822486 712161223 929223279 789135734 360722651 153971744 939870159 397268233 996782603 461946827 415854541 867411675 990092339 598357069 473897275 500810888 275619281 192850236 675529387 873627441 812274819 536498320 608248943 516437352 833348624 413966087 446123228 446763575 37168716 220362967 49788992 897499394 724657501 264359137 563567409 925499718 998213093 968353857 967497437 323504937 534067564 493624945 384737935 4503222 140431245 146730005 712083149 162002919 806573514 701746407 383742728 798711783 776263698 881504931 841731174 305271497 763315656 775870383 150387…
Output: 76025222507

Constraints:

1 <= k <= n <= 1561; -1000000 <= a[i] <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Navigator and the Vermilion ribbons - MEDIUM Coding Problem | CodeTikki