On a table there are $N$ stacks. Stack $i$ contains $i$ tokens. Minimum number of moves to make all stacks empty.

51 Views Asked by At

On a table there are $N$ stacks (numbered 1 to $N$). Stack $i$ contains $i$ tokens ($1≤i≤N$). During a move, a set of stacks can be chosen, and the same number of chips can be drawn from each stack that is part of the chosen set. What is the minimum number of moves to make all stacks empty? For example, if $N=3$, the answer is 2. On the first move, you can choose stacks 2 and 3 and remove 2 chips from them and in the second move you can choose stacks 1 and 3 and remove one chip from them.

My approach would be to split the stacks in half and removing $n/2$ tokens from the second half. Now, the problem size is reduced in half, and we can solve it recursively.

I don't know if this approach results in the minimum number of moves or if it does how to prove it.

1

There are 1 best solutions below

0
On

I believe your approach is optimal and you can prove it if you state the rule more carefully. If the tallest stack has $N$ coins you should remove $\left \lceil \frac N2 \right\rceil$ coins from all stacks that have enough. This will leave you with $\left\lfloor \frac N2 \right\rfloor$ coins in the tallest stack.

First argue that having multiple stacks of the same number doesn't matter as they will all get cleared together. Next show that you will always have stacks from $1$ up to the maximum, so you are truly reducing to a smaller problem. Finally show that removing this number results in the least coins in the tallest stack.