hi i am getting right anwer for all the given car configuration i tried around 60 test cases all the time i am getting correct answer but still it is giving wrong answer
please help
my code is:
#include<stdio.h>
int main(void)
{
for(;;){
int n,a[2000],l=0,b[2000],c[2000],d[2000],i,j,k,count;
scanf("%d",&n);
if(n==0){break;}
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
b[i]=0;c[i]=0;
}
j=1;count=0;k=n;
for(i=0;i<n;i++)
{
if(k==0)
k=1;
if(a[i]==j||c[k]==j)
{
b[count]=j;
if(a[i]==j){a[i]=0;}
if(c[k]==j){k++;}
count++;j++;
}
else
{ k--;
c[k]=a[i];
a[i]=0;
}
}
for(i=0;i<n;i++)
{
d[i]=c[i]+b[i];
if(d[i]!=i+1 && d[i]!=0 && d[i]!=i)
l++;
}
if(l>0)
{
printf("no\n");
}
else
printf("yes\n");
}
return 0;
}