Max Adds
You are given $2$ integers $N$ and $M$, and $2$ arrays $A$ and $B$. Define $f(X)$ as follows: - Start with $Y = X$. - For each $i = 1, 2, \ldots, N$ in this order: Update $Y = \max(Y + B_i, A_i)$ - $f(X)$ is the final value of $Y$. Find $\sum_{i = 1}^{M} f(i)$, i.e. $f(1) + f(2) + \ldots + f(M).$ ### Input - The first line of input will contain a single integer $T$, denoting the number of test
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start