I am solving this question, Here is my solution.
I am getting WA, I am unable to find the error in my logic.
I read the editorial from this page, but I am unable to understand any thing.
I will be very thankful if any one can help me finding mistake and elaborate the editorial.
Thank You