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;
}
上一篇:MySQL 主从同步报1236错误


下一篇:2020 BIT冬训-C++STL A - 排名 HDU - 1236