1075. PAT Judge (25)
2017-05-10 19:57
260 查看
//分数相同按解决问题的数量 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct pat { int problems[6]; int problems_flag; int score; int sloved; int id; int rank; }stu[10010]; bool cmp(pat a, pat b) { if(a.score != b.score) return a.score>b.score; else if(a.sloved != b.sloved) return a.sloved>b.sloved; else return a.id<b.id; } int main() { int N=0,K=0,M=0; int full_mark[6]={0},i=0,j=0; int id=0,no=0,score=0; scanf("%d%d%d",&N,&K,&M); for(i=1; i<=N; i++) { stu[i].id = i; stu[i].problems_flag = false; memset(stu[i].problems,-1,sizeof(stu[i].problems)); } i = 0; while(i<K) { scanf("%d",&full_mark[i+1]); i++; } j = 0; while(j<M) { scanf("%d%d%d",&id,&no,&score); if(score >=0 ) //提交且编译通过 { stu[id].problems_flag = true; } if(score == -1 && stu[id].problems[no] == -1) { stu[id].problems[no] = 0; } if(score>stu[id].problems[no]) //记录最高分 { //获得满分,解决数量加1 if(stu[id].problems[no] != full_mark[no] && score == full_mark[no]) stu[id].sloved += 1; //更新最高分 stu[id].problems[no] = score; } j++; } for(i=0; i<=N; i++) { for(j=1; j<=K; j++) if(stu[i].problems[j] != -1) stu[i].score += stu[i].problems[j]; } sort(stu+1,stu+N+1,cmp); stu[1].rank = 1; for(j=2; j<=N; j++) { if(stu[j].score == stu[j-1].score) stu[j].rank = stu[j-1].rank; else stu[j].rank = j; } for(j=1; j<=N; j++) { if(stu[j].problems_flag==true) { printf("%d %05d %d",stu[j].rank,stu[j].id,stu[j].score); for(i=1; i<=K; i++) { if(stu[j].problems[i] == -1) printf(" -"); else printf(" %d",stu[j].problems[i]); } printf("\n"); } } return 0; }
相关文章推荐
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)解题报告
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 经验总结25--释放内存的重要性
- 【剑指offer】面试题25:从上往下打印二叉树
- PAT 1051. Pop Sequence (25)
- 1010. 一元多项式求导 (25)
- 1055. The World's Richest (25)
- 7-85 红色警报(25 分)
- PAT 1024. Palindromic Number (25)
- PAT 甲级 1012. The Best Rank (25)
- 9.8 给定数量不限的硬币,25,10,5,1,编写代码计算n分有几种表示法。
- 1133. Splitting A Linked List (25)