openjudge删除数组中的元素(链表),我是个新手,我在我电脑上跑得过,但是交到openjudge总是Time limit exceeded?是我代码有问题吗?

#include
#include

typedef struct _node
{
int data;
struct _node *next;
} node;

int main(void)
{
node head, *p, *t, *first, *second;
int n, x;
scanf("%d", &n);
head = (node
)malloc(sizeof(node));
head->next = NULL;
p = head;
for(int i=0; i {
scanf("%d", &x);
t = (node*)malloc(sizeof(node));
t->data = x;
t->next = NULL;
p->next = t;
p = t;
}
scanf("%d", &x);
for(int i=0; i {
first = head;
second = head->next;
while(second != NULL && second->data != x)
{
first = second;
second = second->next;
}
if(second != NULL)
{
p = second;
first->next = second->next;
free(p);
}
}
p = head->next;
while(p != NULL)
{
printf("%d ", p->data);
p = p->next;
}
p = head->next;
while(p != NULL)
{
head->next = p->next;
free(p);
p = head->next;
}
free(head);

return 0;

}

for(int i=0; i {
鬼知道你写了什么玩意