← All problemsSign in

Non-Negative Sum

CodeChefRating 944Open on judge ↗

You have an array $A$ of $N$ integers - $[A_1, A_2, \ldots, A_N]$. Find the largest subsequence of this array with a non-negative sum. If no such subsequence exists, print $0$ instead. ---- $B$ is said to be a subsequence of $A$ if $B$ can be formed by deleting several (possibly $0$) elements from $A$ without changing the order of the remaining elements. For example, $[2]$, $[1, 3]$ and $[1, 2

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