A complete closed-form solution to a tropical extremal problem