Skip to content

Commit 51b949b

Browse files
authored
Update Lagrange.mdx
1 parent 4a75af8 commit 51b949b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

content/6_Advanced/Lagrange.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ because we either begin a new subarray or we continue an existing subarray.
6666

6767
Let $v$ be the maximal achievable sum with $\lambda$ penalty and $c$ be the number of subarrays used to achieve $v$. Then the **maximal possible sum achievable if we use exactly $c$ subarrays is $v+\lambda c$**. Note that we add $\lambda c$ to undo the penalty.
6868

69-
Our goal is to find some $\lambda$ such that $c=k$. As we increase $\lambda$, it makes sense for $c$ to decrease since we are penalizing subarrays more. Thus, we can try to binary search for $\lambda$ to make $c=k$ and set our answer to be $v+\lambda c$ at the optimal $\lambda$.
69+
Our goal is to find some $\lambda$ such that $c=K$ (assuming $K$ is at most the number of positive elements). As we increase $\lambda$, it makes sense for $c$ to decrease since we are penalizing subarrays more. Thus, we can try to binary search for $\lambda$ to make $c=K$ and set our answer to be $v+\lambda c$ at the optimal $\lambda$.
7070

7171
This idea almost works but there are still some very important caveats and conditions that we have not considered.
7272

0 commit comments

Comments
 (0)