题意:按成绩排序

思路:排序

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std; struct node{
char name[];
int grade;
}a[]; bool cmp(node a,node b){
if(a.grade!=b.grade)return a.grade>b.grade;//降序
return strcmp(a.name,b.name)<;//升序
} int main(){
int n,m,g,i;
int sco[];
int m2,num;
int sum; while(~scanf("%d",&n)&&n){
memset(a,,sizeof(a));
sum=;
scanf("%d%d",&m,&g);
for(i=;i<=m;++i)
scanf("%d",&sco[i]);
for(i=;i<n;++i){
scanf("%s",a[i].name);
scanf("%d",&m2);
while(m2--){
scanf("%d",&num);
a[i].grade+=sco[num];
}
if(a[i].grade>=g)++sum;
}
sort(a,a+n,cmp);
printf("%d\n",sum);
for(i=;i<n;++i){
if(a[i].grade<g)break;
printf("%s %d\n",a[i].name,a[i].grade);
}
}
return ;
}
05-11 09:41
查看更多