CT36862

The segments at Bluehollow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the indigo vats of Bluehollow with crates of segments, and Peddler the scribe must account for every last one. 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 <= 1706; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 1323 889 -882797 721992 -427043 -95310 -662753 -251062 270489 -752750 138560 -696099 82343 223228 -755060 -406207 -88612 -615115 642899 -888305 173380 548883 -514541 521127 -519569 -137394 857959 322292 967252 -503297 -336964 -564952 317745 -305196 461009 458397 346958 457226 -153912 960490 -634976 636868 -907046 -840676 872837 423694 895203 659814 317133 -748878 934521 -468903 -412945 -557849 -683585 241670 -270139 -284934 -857828 -494579 -978812 -647271 184490 -26437 49760 -479273 -792541 524626 773542 -289586 -810335 -813766 289972 -143373 450363 -774872 -649279 -523354 22174 -765918 16474 -530889 290346 -183920 -966909 -565243 773483 -734161 -353356 330733 595387 -320828 -528070 347516 609547 68223 -848429 916399 -425406 640927 -280710 601098 200992 350103 -927780 -978816 592384 400726…
Output: -5354232

Example 2:

Input: 618 229 -695568 504576 -824103 736556 -358746 -6541 -457264 457617 876846 989918 -58290 -820018 905045 215596 -937953 -309008 -804317 -332298 -853663 495691 327329 -482296 -261182 -326134 -589579 -379220 -738300 -373280 432426 875611 -772461 350316 707656 -156720 -88981 128181 863384 431747 535413 -593 -518240 265536 -858039 130581 -135132 -629463 -983341 757836 -440762 -856286 435464 55692 610335 -223754 -193458 -922008 527296 -791245 545144 234072 862449 -601446 913541 692635 -761612 -650992 831308 -247061 81616 509446 -734297 243111 857290 360290 -37075 321544 798403 -262369 -312181 -860923 748692 -306652 286249 -832855 -78077 -307710 934228 -129989 -239335 -738786 -783044 790941 872453 101395 46650 -989711 714423 100241 -75352 -937798 23131 -433325 258430 587509 824396 646445 -836710 2…
Output: 16317298

Example 3:

Input: 1479 692 884015 554105 -689449 771758 -199501 346051 460021 -373648 -391169 499494 395721 -797442 -944372 -245354 -140057 61717 726155 533329 972810 -722641 -151745 218896 -366507 333071 44493 -206275 174728 -579118 849029 124696 495198 -468906 577283 155963 -842614 -895714 692838 -241992 252082 140892 -854856 978334 492613 495868 465510 -68036 226292 -913470 965318 990427 309407 737795 -57971 -170673 88481 -402714 -812785 120620 404096 868353 902821 -20503 403373 578644 127353 685584 -518481 491263 47310 922070 -238 -250712 -894560 -478630 -456078 773508 -424230 728376 -159223 -288541 640049 484934 455280 824690 -340336 269402 409458 -130058 -666388 401660 727745 899693 -746413 -586875 -507013 -104358 -532606 60535 -869662 -487636 -964785 -881049 -622604 90653 -298691 -500961 -873911 -782…
Output: 7982876

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The segments at Bluehollow - MEDIUM Coding Problem | CodeTikki