Coach Academy interview question

Solve Problem on Vjudge with python