WA in SWPDGT

CodeChef: Practical coding for everyone can somebody help me why am i getting wrong answer in it it works fine in all the cases.