标签:des style blog http io ar color os sp
4 5 25 10 10 12 13 15 CS004 3 5 1 3 CS003 5 2 4 1 3 5 CS002 2 1 2 CS001 3 2 3 5 1 2 40 10 30 CS001 1 2 2 3 20 10 10 10 CS000000000000000001 0 CS000000000000000002 2 1 2 0
3 CS003 60 CS001 37 CS004 37 0 1 CS000000000000000002 20HintHuge input, scanf is recommended.
//真的醉了,Runtime Error一晚上。。。 //最后将结构体从下标1开始存,AC了。。。 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct st { char xuehao[22]; int fen; }data[1010]; int cmp(st a,st b) { if(a.fen!=b.fen) return a.fen>b.fen; else if (strcmp(a.xuehao,b.xuehao)<0) return 1; else return 0; } int main() { int i,n,m,l,x,k,sum,ans; int c[20]; while(scanf("%d",&n)&&n) { scanf("%d %d",&m,&l); memset(c,0,sizeof(c)); for(i=1;i<=m;i++) { scanf("%d",&c[i]); } for(i=1,ans=0;i<=n;i++) { sum=0; scanf("%s %d",data[i].xuehao,&k); while(k--) { scanf("%d",&x); sum+=c[x]; } data[i].fen=sum; if(data[i].fen>=l) ans++; } sort(data+1,data+n+1,cmp); printf("%d\n",ans); for(i=1;i<=ans;i++) printf("%s %d\n",data[i].xuehao,data[i].fen); } return 0; }
标签:des style blog http io ar color os sp
原文地址:http://blog.csdn.net/hdd871532887/article/details/41815837