WA in CHEFPSA

https://www.codechef.com/viewsolution/28844340

Can any one find the mistake in my above code ?
Thanks in advance !