CT39494

The Fixed Window Peak at Barking Cove

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the seal rocks of Barking Cove with crates of windows, and Librarian the reckoner 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 <= 3926; 1 <= a[i] <= 1000000000.

Example 1:

Input: 927 245 663913482 311449316 267741484 185096810 210812398 313734638 404548205 358910176 239427589 77851849 445017033 492083171 137186463 159051419 723884157 886273461 667311763 296484953 415092469 736093186 136698849 984861043 733127102 918019167 468023040 791953492 899268058 157515727 850662045 586653559 476540986 12536469 393008948 422017507 45372455 848836567 941517073 81895545 637828877 630634521 883634080 757716888 224970730 11912280 56662452 11776535 355222693 803218868 477381162 2230647 421096317 935356465 824561859 547565854 760849735 277518606 918003338 900986694 994013513 154055769 705483302 699066066 544686923 832622456 235742186 60549684 224847026 913923205 124687511 979929249 845729092 525896410 623321546 630501601 558230452 497012939 141472292 460591746 603130186 228111889 71…
Output: 123973070946

Example 2:

Input: 710 235 835079346 141647268 911687927 317642749 109384438 375273253 240946601 168940863 364959901 655389897 476697429 150098817 256401406 727232420 298711421 852926763 589710990 158419350 379616744 807633569 425467803 814967625 738348514 832334783 605644244 82847008 157454895 617697903 595353229 877816140 374658591 455032195 666579014 920209485 976787599 674832232 492840624 721282204 533630333 311241361 608834679 826437922 465147306 808406861 114772282 818128362 78632262 871624751 295853846 285051608 874279100 899979038 843515857 341061354 472403154 892609748 449704114 552762060 701163194 989851208 960808835 507465419 92840474 919917900 961253081 129832444 950229267 283012634 813347436 196543595 523647312 885209776 162533972 475859637 255541486 92342198 787175772 881915282 758738708 250162…
Output: 128833764743

Example 3:

Input: 2084 1478 501158375 940542190 491046383 231551555 347762966 813758257 8653108 204823588 529740641 754339388 920656246 751797141 823089621 877574372 647223282 436458101 552966555 739349264 249632244 463165499 665661134 769610985 690402162 967253747 270198372 27801570 540801733 995135761 750644396 290492102 872232297 769459904 275092796 803727699 509078647 832443470 508384936 854587168 231696761 35792138 110338486 721380005 212525295 711827399 652727826 620677729 897417675 70317274 167845701 14201533 911741537 90961963 850190422 653107187 769925120 983472534 148119186 250087951 609354814 8148624 322203665 901904336 817002419 402107448 202636019 993057985 884450328 978304211 613811499 792559703 26072970 881104827 91955281 744439610 315602649 20876886 13160909 798661538 6855410 930180368 95843…
Output: 741743129755

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Fixed Window Peak at Barking Cove - MEDIUM Coding Problem | CodeTikki