Pile of blocks problem

Question

Hints

Answer