CT44150

Ravi Counts the panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the silver mines of Lodebarrow, someone must plan the beacon maintenance rota. This year the task falls to Ravi, armed only with the panels register. 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 <= 1211; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1200 511 223786296 526124657 395593802 961438315 806926312 677050476 827191876 129808010 536485368 762627184 62665632 643954506 606179314 396043790 750801815 781926392 645276931 659524604 63230949 695998755 668380858 399097432 37306189 544516889 128174206 924337004 671597172 878134930 816413462 314398454 913071225 779474936 222731071 499023157 789354731 722392821 78694950 775073579 782740466 244266152 605571455 429700438 525825061 614992797 339967801 703818092 424558794 962796556 612904919 172901667 891793269 529509230 359686627 462865064 973780217 349698729 507929503 11947629 91616006 594726217 305797235 792655311 646923934 249076794 395836658 945647762 238283819 133063861 80839164 711222694 831737256 811043708 862412205 951802787 676457513 617947465 252038771 658019960 751100764 46367298…
Output: 271614098255

Example 2:

Input: 385 340 813741293 154403615 571988018 487012011 897410728 233743032 106515819 24658510 551748629 328772531 751704020 87099588 861101964 170407141 299079847 432736184 235881969 236217381 418603561 530230456 786588416 969481020 290210884 554836187 328123492 492200629 915091798 903584285 522689490 772192432 687306917 575875143 392293723 364490149 357856513 512101245 912778824 980709139 501769475 464802918 683056301 760155424 45545977 914141374 38828374 924578504 702475090 990563009 147814038 754698964 20471148 908187318 757468562 934415197 93846904 993530043 357815257 912266760 590560752 186462745 894651633 941963650 891503614 486380345 562162413 170396216 705511269 931548826 627302015 940686235 541479012 771758486 774599567 239889546 857047476 164971275 878477652 349393258 121910684 49564732…
Output: 181507614994

Example 3:

Input: 151 102 85501569 837458823 969847178 974397362 213623796 98392090 230634891 564707585 358908050 35847790 368914547 434524890 15696685 679605439 436116522 428563930 307667007 724537563 202303008 292072119 624026475 830080394 979168948 209825143 660976697 653457707 180934235 820089887 682167106 997319764 321432943 566358588 206658241 122539943 15156566 801442950 349679974 262461556 331777749 14417311 727159790 746696770 836285696 88060625 282614997 184763319 910283338 721429616 68841098 753370065 72936435 208067883 959323586 271409936 289571077 475310295 302973600 111694838 573777384 84542346 995411448 394365844 636729865 568233434 105758481 537428824 506628720 517674570 464814220 946586292 964578958 768069880 272218237 621264489 513468036 290655701 556110453 992513850 945180694 170335166 98…
Output: 50958236219

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Ravi Counts the panels - MEDIUM Coding Problem | CodeTikki