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;
}
#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;
}
- HDU 1177 ( "Accepted today?" )
- HDU-1177"Accepted today?"
- hdu-1177-"Accepted today?"
- HDU 1177 "Accepted today?" 水题
- HDU杭电 1177 Accepted today
- 1177"Accepted today?"
- hdoj 1177 "Accepted today?"
- HDU--杭电--1177--"Accepted today?"--结构体排序
- 杭电1177-Accepted today
- HDOJ 1177 "Accepted today?" (简单模拟)
- HDU1177:"Accepted today?"
- hdu1177("Accepted today?")
- HDU1177 "Accepted today?"
- hdu1177:"Accepted today?" 之基数排序
- HDU 1177."Accepted today?"【结构体排序(水)】【1月6】
- HDU Today
- HDU Today
- HDU Today
- php中的cookie用法
- left join,inner join,right join,cross join,full join的区别
- Java处理带BOM的文本
- CString 与 char 与 BYTE 之间的转换
- java项目内存溢出问题解决方法
- hdu-1177-"Accepted today?"
- 使用多线程的利弊
- 进程间通信(1) - IPS概述
- android中SharedPreferences的使用
- 抄书:C++ string
- Android中dip、dp、sp、pt和px的区别
- 构造函数/复制构造函数/析构函数/赋值操作符的总结
- 从01背包问题走进动态规划
- 恒大赢了!!!