Getting wrong ans

https://codeforces.com/contest/1372/problem/C

my soln-https://ide.codingblocks.com/s/284190

i my solution i am getting wrong ans in 5th test case. please tell me how to correct it and tell me my approach is correct or not

please read the editorial u are missing some corner case

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.