CodeChef: Practical coding for everyone[my solution] question
You should check the editorial editorial