hdu 4557 (水)

点击打开链接



#include"stdio.h"
#include"string.h"
#include"stdlib.h"
struct node
{
	int x;//能力值
	int k;//标记
	int y;//标号
	char str[20];//名字
}A[1001];
int num;
int cmp(const void*a,const void*b)
{
	struct node *c,*d;
	c=(struct node*)a;
	d=(struct node*)b;
	if(c->x!=d->x)return c->x-d->x;
	return c->y-d->y;
}
void add(char *p,int a)
{
	A[num].x=a;
	A[num].y=num;
	A[num].k=1;
	strcpy(A[num].str,p);
	num++;
	int t;
	t=0;
	for(int i=0;i<num;i++)
	{
		if(A[i].k==1)t++;
	}
	printf("%d\n",t);
}
void find(char a)
{
	int i;
	for(i=0;i<num;i++)
	{
		if(A[i].x>=a&&A[i].k==1)
			break;
	}
	if(i>=num)printf("WAIT...\n");
	else
	{
		printf("%s\n",A[i].str);
		A[i].k=0;
	}
}
int main()
{
	int T;
	int t=1;
	int n,a;
	char s[10],ss[20];
	scanf("%d",&T);
	while(T--)
	{
		num=0;
		scanf("%d",&n);
		printf("Case #%d:\n",t++);
		while(n--)
		{
			scanf("%s ",s);
			if(s[0]=='A')
			{
				scanf("%s%d",ss,&a);
				add(ss,a);
				qsort(A,num,sizeof(A[0]),cmp);				
			}
			else if(s[0]=='F')
			{
				scanf("%d",&a);
				find(a);
			}		
		}
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值