1075. PAT Judge (25)
来源:互联网 发布:mac磁盘越来越小 编辑:程序博客网 时间:2024/06/06 02:07
//分数相同按解决问题的数量#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;}
0 0
- PAT 1075. PAT Judge (25)
- PAT 1075. PAT Judge (25)
- 【PAT】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)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- 1075. PAT Judge (25)
- codeforce Gym100269F——Flight Boarding Optimization(动态规划)
- HttpClient测试接口的封装(get和post)
- 5-11 关键活动
- QT 将含有中文字符的QString转化为char*类型
- 深入解析MySQL分区(Partition)功能
- 1075. PAT Judge (25)
- [leetcode:python]38.Count and Say
- 如何解决 Notice: Undefined index: submit in D:\wamp\www\bbs\add.php on line 9
- 建站工具
- 【tyvj4089】n^2(dp)
- Linux之使用MogileFS分布式文件系统并使用nginx实现反向代理
- IO流(1)--字节流
- Android Studio中JNI NDK开发(三)
- 常见dom树操作