CodeChef: Practical coding for everyone
Editorial for this problem will be released by today night.
thanks