我为codechef中的一个问题编写了此代码。尽管它在我的IDE中给出了正确的答案,但Codechef IDE表示这是错误的答案,有时表示已超过了时间限制。( 。)有人可以告诉我为什么会发生这种情况,我该如何解决?这是问题和我的代码。
https://www.codechef.com/problems/PIPSQUIK/
#include<stdio.h>
int main(void)
{
int t,n,h,ya,yb,l,ti,x;
int count;
int i,f,g;
scanf("%d",&t);
for( i = 0 ; i < t ;i++)
{
scanf ("%d %d %d %d %d",&n,&h,&ya,&yb,&l);
count = 0;
for ( g = 0 ; g < n ; g++)
{
scanf("%d %d",&ti,&x);
if( ti == 1 && h - ya <= x || ti == 2 && yb >= x)
{
count++;
}
else
{
l--;
count++;
}
if (l == 0)
{
count--;
break;
}
}
printf("%d\n",count);
}
return 0;
}