← All problemsSign in

G - Penny Pinching

For an array $b = [b_1, b_2, \ldots, b_{m}]$ of length $m$ and a binary string $t$ of length $p$ such that $p < m$, we define $\text{score}(b, t)$ as follows. Iterate $i = 1, 2, \ldots, p$ in order. - If $t_i = 0$, delete $b_1$ from $b$. - Otherwise, delete $b_2$ from $b$. - The remaining elements are then re-indexed to start from $1$. After all elements of $t$ have been processed, $b$ will have

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