← All problemsSign in

H - Prefix Game

Alice and Bob are playing a game. There are $n$ piles of stones, denoted by the array $a$, with the piles satisfying the condition that $a_1 \ge a_2 \ge \dots \ge a_n$ (that is, the piles are arranged in non-increasing order). On their turn, a player can choose an index $i$ ($1 \le i \le n$) and a **positive** integer $x$, and take $x$ stones from each of the piles $a_1, a_2, \dots, a_i$. How

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