MULTHREE DSA first week

The below code is for MULTHREE of the first week of DSA.I tried testing it for all possible corner cases I could and it’s giving correct answer,but still the solution is not accepted.
I have used the similar logic of the editorial,but I couldn’t figure out what is going wrong in my code,please help
https://www.codechef.com/viewsolution/34511240