List of books is a problem I found in IARCS online problem archive. But their judge is showing wrong answer to my solution. I don’t know what went wrong? Is my algorithm is totally a fail? or some silly mistake which I neglected?

Please help.

```
#include<stdio.h>
int main()
{
int i,j,m,p[1000001],s[4001][3],n,t,r,left=0,right=0;
scanf("%d",&m);
for(i=1;i<=m;i++)
scanf("%d ",&p[i]);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&s[i][0]);
s[i][1]=0;
s[i][2]=0;
}
for(i=2;i<=n;i++)
{
for(j=i-1;j>=1;j--)
{
if(s[i][0]>=s[j][0])s[i][1]++;
//else s[i][2]++;
}
}
for(i=1;i<=n;i++)
{
printf("%d\n",p[s[i][0]+s[i][1]]);
}
return 0;
}
```