← All problemsSign in

Sum of Subarrays Again

CodeChefRating 2094Open on judge ↗

For an array $A$ where $A_i \ne 0$, we define $f(A)$ as $\max(f_i(A))$ for $0 \le i \le N$, where $f_i(A)$ is computed as follows: - $f_0(A) = \sum_{j = 1}^{N} A_j$ - If $A_i > 0$, $f_i(A) = (\sum_{j = 1}^{i - 1} |A_j|) - A_i + (\sum_{j = i + 1}^{N} A_j)$ - If $A_i < 0$, $f_i(A) = -10^{18}$ If you think these functions are strange, you can note $f(A)$ as the answer (as in the maximal possible su

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start