← All problemsSign in

Positive-Negative

CodeChefRating 1770Open on judge ↗

Alice and Bob have with them an array $A$ of length $N$. It is known that $A_i = 1$ or $A_i = -1$ for each $1 \le i \le N$. It is also guaranteed that there exists at least one index satisfying $A_i = 1$. They will play the following game on it: - On Alice's turn, she must choose two integers $L$ and $R$ such that $1 \le L \le R \le |A|$ and $A_L + A_{L+1} + \ldots + A_R \ge 0$, and delete

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