Shopping Game problem

https://ide.codingblocks.com/s/288772- code is pass for sample case only. What is the error?

Please save your code after pasting it in the online IDE.
And then send the link.

I have again saved…this code will not worked for some test case

In this question, we don’t have to consider two separate loops. We have to do it using a single loop.
Its like first aayush purchases 1, then harshit purchases 2, then aayush 3 and so on. Break out from the loop if any of the count exceeds the maximum for the person.

for(long long int i=1;;i++)
{
    	if(i&1)   //aayush will purchase
    	   p = p + i;
    	else
    	   q = q + i;
    				
    	//check
    	if(p>a)
    	{
    			cout<<"Harshit"<<endl;
    			break;
    	}
    			
    	//check
    	if(q>h)
    	{
    		cout<<"Aayush"<<endl;
    		break;
    	}	
}

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.