i solved this problem and submitted got WA.and i almost covered almost all cases after seeing editorial also…can anyone gives the testcases where may be the code gets wrong.
and my code solution link is
https://www.codechef.com/viewsolution/30083100