Codechef problem

I had solved this question using dis approach…
please tell me what I am doing wrong
here is the question link

here is my code