hdu-1177-"Accepted today?"

来源:互联网 发布:买买提网络意思 编辑:程序博客网 时间:2024/06/17 21:28
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct in
{
int p;
char t[9];
}q[135];
int cmp(const void *a,const void *b)
{
struct in *c=(struct in *)a;
struct in *d=(struct in *)b;
if(c->p!=d->p)
return d->p-c->p;
else
return strcmp(c->t,d->t);
}
int main()
{
int n,g,s,c,m;
while(scanf("%d%d%d%d%d",&n,&g,&s,&c,&m)&&(n+g+s+c+m))
{
int i,j,k=0;
char w[9];
for(i=0;i<n;i++)
{
scanf("%d%s",&q[i].p,q[i].t);
if(i==m-1)
{
j=q[i].p;
strcpy(w,q[i].t);
}
}
qsort(q,n,sizeof(q[0]),cmp);
for(i=0;i<n;i++)
{
k++;
if(q[i].p==j&&strcmp(q[i].t,w)==0)
break;
}
if(k<=g)
printf("Accepted today? I've got a golden medal :)\n");
else if(k<=g+s)
printf("Accepted today? I've got a silver medal :)\n");
else if(k<=g+s+c)
printf("Accepted today? I've got a copper medal :)\n");
else 
printf("Accepted today? I've got an honor mentioned :)\n");
}
return 0;
}
原创粉丝点击