Wrong answer for correct code

Hey, could you please check what is wrong with my code, the logic is correct. It behaves differently for different number of queries

This is my code: https://onlinegdb.com/OD00SbY33K

Hi… so there were 2 minor mistakes in ur code…
firstly cin>>t statement was missing… secondly endl statement was placed at wrong position…
i have corrected ur code https://ide.codingblocks.com/s/598734 … its working fine now

Ohh, thanks. This was so silly

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.