CT51206

Gardener and the Pale panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the lakeside town of Mirrormere opens only for a perfect tally of panels. Gardener means to find out. 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 <= 2618; 1 <= a[i] <= 1000000000.

Example 1:

Input: 1285 1105 736068544 136974238 827357166 949543375 926396778 351605639 342867170 279878587 395721948 816005803 954851192 104442090 520826235 440867727 182106903 523151214 174966026 819623184 393018679 935038832 334538561 999152314 988169152 151459176 339833850 979657978 575286218 977844210 155689817 945675918 360754140 452099439 258546961 999725014 952670421 360004087 452357391 892904684 38203201 922038188 188523880 496831357 238123049 389234223 442307953 950726774 751883562 133461123 301298842 108698131 110018492 595788942 508202056 978470383 137265934 937391411 707918189 91484638 869145205 640389627 391892921 40155964 84460304 921696754 876146155 295002073 79465002 106025735 901745629 311235794 995389924 764358161 879521358 932677320 352725092 561720181 407864703 352982846 888841445 79802…
Output: 528588165413

Example 2:

Input: 1890 1221 322722744 648029786 108309396 480088215 685340541 880109558 73731083 444804553 751284202 980527247 15043931 787170219 401154793 506379451 438407636 89558140 515311038 36696053 130954047 715020147 961922811 1468580 740736419 758086746 25532209 200574653 694437423 292810871 712531246 231402342 87930160 873355429 73169923 664174594 142972835 502403912 819070721 52443811 417536137 940021968 61800457 409086460 105211835 448655973 142321901 179418883 51941123 855909610 215452713 810846753 60363175 573447504 890560263 939010542 870163648 631760135 878747088 93791851 40787703 961640148 858730699 232259698 335464782 101016601 169852108 300989343 369539271 547937852 206794409 918918093 713443165 272649756 776243064 952775912 708460843 176430883 713158858 111222723 173513790 699716684 84944…
Output: 621319111665

Example 3:

Input: 1402 388 573637671 934397793 605234375 819681457 168791875 699938261 121305126 735708616 259264794 479621915 71571452 498122624 851637904 879551128 4525764 396170618 32001195 715865811 475805475 739863811 181777685 472389564 293801940 876528564 399368347 509583131 208075966 715667106 615593737 409565256 328405627 845170690 679784731 839455433 455337369 279041524 162269839 270410472 215888856 22718225 967661844 961986140 806641886 354999933 910072316 113728044 665260176 445671245 432940144 242039403 499764606 297931777 725454035 96893815 545363792 335835585 764764766 332377662 987565300 75177036 943006050 415001335 462790781 691719295 821177308 788072835 579125446 380880888 237094659 975876324 937274426 175005331 787028436 20206806 38317610 110382335 169930372 171559440 41778608 550330462 6…
Output: 205057522187

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Gardener and the Pale panels - MEDIUM Coding Problem | CodeTikki