Pirate game problem

Question

Hints

Answer