← All problemsSign in

Good Sequence

CodeChefRating 2451Open on judge ↗

Suppose you have a **binary** array $B$ of length $N$. A sequence $x_1, x_2, \ldots, x_k$ is called *good* with respect to $B$ if it satisfies the following conditions: - $1 \leq x_1 \lt x_2 \lt \ldots \lt x_k \leq N+1$ - For *every* pair $(i, j)$ such that $1 \leq i \lt j \leq k$, the subarray $B[x_i: x_j-1]$ contains $(j-i)$ more ones than zeros. - That is, if $B[x_i : x_j-1]$ contains $c_

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