PIPSQUIK-CAN ANYBODY HELP ME OUT

here is the problem statement:


here is my code ,plz help me out to find the fault:

#include

using namespace std;

int main()
{
int T,n,h,y1,y2,l;
cin>> T;
while(T–)
{
int barrier_pass = 0;
cin >> n >>h >> y1 >> y2 >> l;
int temp = l;
int ti[n];
int xi[n];
for(int i=0;i<n;i++)
{
cin >> ti[i];
cin >> xi[i];
if(ti[i]==1)
{
if((h-y1) <= xi[i] && l>0)
barrier_pass++;
else
{
l–;
if(l>0)
barrier_pass ++;
}
}
if(ti[i]==2)
{
if( y2 >= xi[i] && l>0)
barrier_pass ++;
else
{
l–;
if(l>0)
barrier_pass++;
}
}
if(l==0)
break;
}
cout << barrier_pass << endl;
l=temp;

}

}

Remove the lines
if (l==0)
break;
as cin will not run sufficient for a test case so the rest input will interfere in the inputs for next test case.

while (T–) , l-- (there should be 2 - signs)

1 Like

That’s formatting issues. Format your code

1 Like

thanks ,it worked.