其他分享
首页 > 其他分享> > HDU 1236

HDU 1236

作者:互联网

排名

#include<bits/stdc++.h>
using namespace std;
#define MAX 2001
struct chengji{
	char name[100];
	int tm;
	int dd;
	int sum;
}s[MAX];
bool paixu(chengji x,chengji y){
	if(x.sum == y.sum )
		return strcmp(x.name ,y.name )<0? 1:0;
		else 
		return x.sum >y.sum ;
}
int main()
{
	int n,m,average,i,j;
	int a[20],b;
	while(scanf("%d%d%d",&n,&m,&average)!=EOF&&n!=0){
	memset(s,0,sizeof(s));
	for(i=1;i<=m;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++){
		scanf("%s %d",&s[i].name,&s[i].tm  );
		for(j=1;j<=s[i].tm;j++){
			scanf("%d",&s[i].dd );
			s[i].sum =s[i].sum +a[s[i].dd ];
			}
		}
	b=0;
	sort(s+1,s+1+n,paixu);
	for(i=1;i<=n;i++){
		if(s[i].sum >=average){
			b++;
		}
	}
	printf("%d\n",b);
	for(i=1;i<=n;i++){
		if(s[i].sum >=average){
			printf("%s %d\n",s[i].name ,s[i].sum );
		}
		else 
			break;
	}	}
	return 0;
}

标签:HDU,name,int,scanf,1236,average,chengji,sum
来源: https://blog.csdn.net/weixin_52546991/article/details/115706897