码迷,mamicode.com
首页 > 其他好文 > 详细

PAT甲级 1075 PAT Judge (25分)

时间:2020-02-04 10:37:01      阅读:52      评论:0      收藏:0      [点我收藏+]

标签:str   def   std   eof   algorithm   printf   long   解决   using   

//注意:排序的是满分解题数,而不是解题数。
#include <cstdio>
#include <cstring> #include <iostream> #include <algorithm> using namespace std; const int maxn = 200005; typedef long long ll; struct st{ int num,k[6],total_grade,total_q,order,t;//t代表解决题数,total_q代表完美解题数 }s[100005]; bool cmp(st p,st q) {//排序 if(p.total_grade != q.total_grade) return p.total_grade > q.total_grade; else if(p.total_q != q.total_q) return p.total_q > q.total_q; else return p.num < q.num; } int main() { int n,k,kk[6],m; scanf("%d%d%d",&n,&k,&m); for(int i = 1; i <= k; i++) scanf("%d",&kk[i]);//每科满分 int sno,num,grade; for(int i = 1; i <= n; i++) { s[i].num = i; s[i].total_grade = 0; s[i].total_q = 0; s[i].t = -1; memset(s[i].k,-1,sizeof(s[i].k)); } for(int i = 1; i <= m; i++) { scanf("%d%d%d",&sno,&num,&grade); if(grade >=0 ) { s[sno].t = 1; } else grade = 0; s[sno].k[num] = max(s[sno].k[num],grade); } for(int i = 1; i <= n; i++) { for(int j = 1; j <= k; j++) { if(s[i].k[j] != -1) s[i].total_grade += s[i].k[j]; if(s[i].k[j] ==kk[j]) s[i].total_q++; } } sort(s+1,s+1+n,cmp); for(int i = 1; i <= n; i++) { if(s[i].total_grade == s[i-1].total_grade) s[i].order = s[i-1].order; else s[i].order = i; } /*for(int i = 1; i <= n; i++) printf("%d ",s[i].t); printf("\n");*/ for(int i = 1; i <= n; i++) { if(s[i].t == 1) { printf("%d %05d %d",s[i].order,s[i].num,s[i].total_grade); for(int j = 1; j <= k; j++) { if(s[i].k[j] == -1) printf(" -"); else printf(" %d",s[i].k[j]); } printf("\n"); } } return 0; }

 

PAT甲级 1075 PAT Judge (25分)

标签:str   def   std   eof   algorithm   printf   long   解决   using   

原文地址:https://www.cnblogs.com/LLLAIH/p/12258389.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!