Official algorithmic problem description and constraints.
Alice has π magical balls placed on the π₯-axis. The π-th ball is initially at position ππβ and has a power of ππβ.
It is guaranteed that ππ<ππ+1β for 1β€π<π.
Initially, none of the balls are activated.
Alice can do the following at most twice:
When ball π is activated in a certain direction, the following process takes place:
Using at most two moves, is it possible for Alice to activate every ball?
Note that Alice can make her second move only after the entire process from the first move has completed.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.