排名 |
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) |
Total Submission(s): 3690 Accepted Submission(s): 1171 |
Problem Description 今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑 |
Input 测试输入包含若干场考试的信息。每场考试信息的第1行给出考生人数N ( 0 < N |
Output 对每场考试,首先在第1行输出不低于分数线的考生人数n,随后n行按分数从高 |
Sample Input 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 |
Sample Output 3 CS003 60 CS001 37 CS004 37 0 1 CS000000000000000002 20 Hint Huge input, scanf is recommended. |
Source 浙大计算机研究生复试上机考试-2005年 |
Recommend JGShining |
又犯了粗心的毛病,若有多名考生分数相同,则按他们考
号的升序输出。
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 struct Stu 6 { 7 char name[20+5]; 8 int ts; 9 int score; 10 } stu[1000+10]; 11 bool cmp(Stu a,Stu b) 12 { 13 if(a.score!=b.score) 14 return a.score>b.score; 15 else 16 return strcmp(a.name,b.name)<0; 17 } 18 int main() 19 { 20 int n,m,g; 21 int f[10+5]; 22 while(scanf("%d",&n)&&n!=0) 23 { 24 scanf("%d%d",&m,&g); 25 int sum=0; 26 for(int i=0; i<m; i++) 27 scanf("%d",&f[i]); 28 for(int i=0; i<n; i++) 29 { 30 scanf("%s%d",stu[i].name,&stu[i].ts); 31 stu[i].score=0; 32 for(int j=0; j<stu[i].ts; j++) 33 { 34 int x; 35 scanf("%d",&x); 36 stu[i].score+=f[x-1]; 37 } 38 if(stu[i].score>=g) 39 sum++; 40 } 41 sort(stu,stu+n,cmp); 42 printf("%d\n",sum); 43 for(int i=0; i<sum; i++) 44 { 45 printf("%s %d\n",stu[i].name,stu[i].score); 46 } 47 } 48 return 0; 49 }
时间: 2024-10-11 14:20:13