I was trying to find the solution for http://www.codechef.com/CDMU2015/problems/CDMU03 this problem. But i dint succeed in that. So it will be help, if anyone update the editorial for this problem.

Thanks in advance.

I was trying to find the solution for http://www.codechef.com/CDMU2015/problems/CDMU03 this problem. But i dint succeed in that. So it will be help, if anyone update the editorial for this problem.

Thanks in advance.

This question is similar to the question Lisa http://www.spoj.com/problems/LISA/ .Take a look in its editorals.