#include<stdio.h> #include<string.h> #include<stdlib.h> struct cs { char name[100]; int num; int score; }; int main() { struct cs people[1010],x; int N; while(scanf("%d",&N),N) { int M,G,h=0,i,j,s[100],t; scanf("%d%d",&M,&G); for(j=1;j<=M;j++) scanf("%d",&s[j]); for(i=0;i<N;i++) { people[i].score=0; scanf("%s%d",people[i].name,&people[i].num); for(j=0;j<people[i].num;j++) { scanf("%d",&t); people[i].score+=s[t]; } if(people[i].score>=G)h++; } for(i=0;i<N-1;i++) { for(j=0;j<N-1-i;j++) { if(people[j].score<people[j+1].score) { x=people[j+1]; people[j+1]=people[j]; people[j]=x; } if(people[j].score==people[j+1].score&&strcmp(people[j].name,people[j+1].name)>0) { x=people[j+1]; people[j+1]=people[j]; people[j]=x; } } } printf("%d\n",h); for(i=0;i<h;i++) printf("%s %d\n",people[i].name,people[i].score); } //system ("pause"); return 0; }
晕死~~检查几百遍看不出来错在哪。。。。重新写一遍就对了。。。。选择Visual C++,选GNU C++ 会出现 Time Limit Exceeded