Skip to content

Commit fc3ed61

Browse files
Update cses-2416.mdx
1 parent 1bd8634 commit fc3ed61

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

solutions/gold/cses-2416.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ $$
4646
x \cdot (j-i) - \sum_{k=i}^{j-1} \texttt{arr}[k]
4747
$$
4848

49-
The second term is the sum of all elements in the interval $[i,j-1)$.
49+
The second term is the sum of all elements in the interval $[i,j)$.
5050

5151
For example, in that array in Hint 2, $10$ contributes $10 \cdot (2-0)-(10+4)=6$, while $11$ contributes $11 \cdot (4-2)-(11+3)=8$ to the sum.
5252

@@ -61,7 +61,7 @@ First, we have to iterate through the array in reverse.
6161

6262
Let's also keep track of a stack of the values and indices of all the maximums one would get when iterating from an index $i$ to the end of the array.
6363

64-
Taking the array from Hint 2 again. If we were at index $1$, our stack would be $[(11, 2), (4, 1)]$, with the end of the array being the top of the stack.
64+
Take the array from Hint 2 again. If we were at index $1$, our stack would be $[(11, 2), (4, 1)]$, with the end of the array being the top of the stack.
6565

6666
Each element in this stack would contribute the amount given by our formula above to a query's answers, *given that it's completely contained within said query*.
6767

0 commit comments

Comments
 (0)