Result: Accepted
Time: 2ms
Memory: 1792kB
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
struct chengji
{
char name[200];
double score;
int number;
};
int comp(const void*p,const void*q)
{
return((struct chengji*)q)->score-((struct chengji*)p)->score;
}
int main(void)
{
struct chengji a[2000];
int i,n,t,j,p=0;
char b[2000][200];
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;++i)
{
scanf("%s%lf",a[i].name,&a[i].score);
}
qsort(a,n,sizeof(struct chengji),comp);
a[0].number=0;
for(i=1;i<n;++i)
{
if(a[i].score==a[i-1].score)
{
a[i].number=a[i-1].number;
++p;
}
else
a[i].number=i;
}
scanf("%d",&t);
for(i=0;i<t;++i)
{
scanf("%s",b[i]);
strcat(b[i],":");
}
for(i=0;i<t;++i)
{
for(j=0;j<n;++j)
{
if(strcmp(b[i],a[j].name)==0)
printf("%d\n",a[j].number);
}
}
}
return 0;
}