CT39313

Asha and the Pale segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the pine barrens of Needlepoint, someone must reorganize the archive shelves. This year the task falls to Asha, armed only with the segments 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 <= 3056; -1000000 <= a[i] <= 1000.

Example 1:

Input: 646 210 -869287 -145633 -734051 -32557 -492949 -553587 -677857 -184735 -875602 -141865 -496075 -522902 -674888 -125499 -651595 -613152 -116290 -120436 -147531 -84618 -237967 -306175 -418937 -825812 -411267 -297649 -507137 -105 -751128 -628932 -356619 -465250 -200639 -414924 -1268 -266059 -575386 -767600 -701737 -661506 -366433 -143917 -626729 -168590 -277439 -300240 -71931 -177565 -418580 -671364 -427421 -434177 -272901 -650594 -682386 -863710 -799601 -222357 -119096 -529705 -22737 -321954 -94198 -709776 -999115 -455678 -449054 -943259 -268036 -56464 -14676 -332754 -413536 -339058 -628563 -607969 -943529 -944923 -530264 -336918 -71097 -22657 -850651 -923532 -728026 -570337 -549245 -18565 -982349 -106036 -203815 -554151 -687089 -535190 -976810 -854459 -420695 -771025 -477153 -550876 -426770…
Output: -99086164

Example 2:

Input: 2746 2428 -698651 -248966 -828856 -406011 -648208 -683317 -509469 -89038 -36001 -193311 -219203 -896478 -298145 -217175 -120501 -524751 -321815 -965644 -295709 -299368 -526271 -565050 -728661 -396887 -284877 -88512 -514379 -19261 -556504 -662051 -36298 -468552 -650569 -452621 -616752 -427097 -606727 -71618 -531920 -793970 -685405 -719554 -513360 -914957 -194247 -214774 -108047 -65831 -700677 -963184 -851594 -479825 -940455 -730197 -124188 -381519 -535361 -595073 -779159 -965088 -195685 -762372 -26345 -411023 -245822 -91928 -948590 -959158 -332316 -78565 -643613 -870527 -33030 -891504 -833095 -609517 -111851 -349143 -840450 -870135 -67256 -23048 -278825 -531037 -106695 -368370 -647415 -283264 -509137 -20261 -741158 -680454 -725301 -296633 -217277 -715518 -705183 -35394 -989745 -221138 -1230…
Output: -1183161402

Example 3:

Input: 1834 1315 -266472 -688565 -895006 -170197 -494942 -733418 -713908 -758459 -999128 -419555 -171971 -669952 -815789 -149982 -436031 -783435 -560674 -650669 -339868 -758571 -196887 -529010 -518634 -740596 -828852 -81653 -789267 -309219 -53914 -637840 -380853 -459217 -486455 -821979 -929863 -158839 -955572 -158840 -359663 -1110 -60695 -76748 -593546 -41547 -467001 -647993 -98639 -932330 -948845 -458425 -278664 -470565 -387665 -29143 -759161 -713134 -321135 -63411 -438903 -304947 -289436 -297738 -922256 -592431 -527604 -724228 -812575 -209911 -998597 -689140 -585526 -530029 -36296 -915506 -405638 -85162 -2640 -989149 -357660 -368390 -784856 -612873 -755267 -447274 -117542 -637060 -147760 -293329 -345956 -536190 -970767 -106298 -750774 -925564 -552358 -318898 -707916 -450711 -472411 -495971 -287…
Output: -650933371

Constraints:

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

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