CT43361

Eklavya's Ledger of segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Eklavya runs the foundry at the garden city of Petalbrook. Today the books show a list of segments, and the numbers must be worked out before sundown. 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 <= 1960; 0 <= a[i] <= 1000000000.

Example 1:

Input: 366 257 236983874 165135166 497460092 529319754 208175772 870388773 793692216 648131238 660438520 443374169 748361608 413254867 192036782 386267913 914161836 152733429 216826614 219018562 789008597 740885062 614674251 186148614 949534701 913744894 762952288 945279159 768818922 164006352 352608676 249856093 991926871 881182903 169793694 181044341 304203275 618941026 315697425 502195568 6985042 470843920 229395053 437503627 982633815 176708114 413388713 375476271 242658547 831687978 229511116 767866628 485708374 942996685 460636931 932797233 663779357 868154808 818921948 674592383 208799377 535328316 432706243 767281674 599446318 27338869 724996138 679443860 164211204 964786072 7707791 324402700 700985819 676626293 781363262 936570287 549491048 219398231 168041375 938281749 697732532 6083484…
Output: 133374291235

Example 2:

Input: 385 306 565407458 744195799 746146393 689199411 342647824 325511118 940631455 19996040 828221809 691723051 606074771 293224075 401178028 358388829 475333216 255531898 52233378 969097745 356576462 505258080 944103754 922862456 55246195 813084633 551984028 686710594 157259510 442588889 582374908 935352117 732890476 708607399 821430301 65120172 397752595 77033217 152360931 456382809 644170709 188209815 689437826 230041151 273423805 978173223 175431571 912084171 656687184 782998336 667054316 928541201 412274290 692330065 155038562 749730066 768050339 130498437 827490812 79083507 610777130 935485073 710729488 517914374 30662620 621545046 776392434 128816814 378873855 869808116 947595461 656926842 269118288 155911341 345022700 112887591 222450879 835502546 825707363 854635611 3826727 491353227 6…
Output: 158765258405

Example 3:

Input: 815 501 755368335 193881779 708778809 574355491 394375713 193426796 962593494 841158228 828398419 113437768 16440706 512266343 289634893 326809362 373517207 208237048 688560300 929573469 906633 579695945 684775620 26002931 305653586 832236199 603603028 929232421 269082369 107546701 238744893 785994604 641900165 356513608 557624228 248967560 389211416 559588626 160854136 288508022 875919118 666105006 847131601 261319084 634885388 676971222 618233470 144340988 959805271 971785036 215260290 52264054 862017048 471824956 895432667 208834002 43594226 935419215 414855748 57023491 58903971 576781579 463040846 299296165 42044792 274548219 636184294 111895329 675856448 70855870 490564155 995164332 772351622 440074766 609011217 809221347 703632030 411459982 916751780 37114590 637122809 946636495 3937…
Output: 241508958125

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Eklavya's Ledger of segments - MEDIUM Coding Problem | CodeTikki