题意:

输入三个正整数N,K,M(N<=10000,K<=5,M<=100000),接着输入一行K个正整数表示该题满分,接着输入M行数据,每行包括学生的ID(五位整数1~N),题号和该题得分(-1表示没通过编译)。输出排名,学生ID,总分和每一题的得分,第一优先为总分降序,第二优先为题目AC数降序,第三优先为学生ID升序(提交但未通过编译得分为0,未提交得分为-,不输出没有提交或者提交全都未通过编译的学生信息)。

trick:

测试点4为有学生先交了得到分的程序后该题后来又交了未通过编译的程序,注意分支结构不要出错。

AAAAAccepted code:

  1. #define HAVE_STRUCT_TIMESPEC
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. typedef struct student{
  5. int id;
  6. int score[];
  7. int sum;
  8. int num;
  9. };
  10. student a[],b[];
  11. int total[];
  12. bool cmp(student x,student y){
  13. if(x.sum!=y.sum)
  14. return x.sum>y.sum;
  15. if(x.num!=y.num)
  16. return x.num>y.num;
  17. return x.id<y.id;
  18. }
  19. int main(){
  20. int n,k,m;
  21. scanf("%d%d%d",&n,&k,&m);
  22. for(int i=;i<=n;++i)
  23. for(int j=;j<=k;++j)
  24. a[i].score[j]=-;
  25. for(int i=;i<=k;++i)
  26. scanf("%d",&total[i]);
  27. for(int i=;i<=m;++i){
  28. int id,num,val;
  29. scanf("%d%d%d",&id,&num,&val);
  30. if(val>-)
  31. a[id].id=id;
  32. else if(a[id].score[num]<)
  33. a[id].score[num]=;
  34. if(val>a[id].score[num])
  35. a[id].score[num]=val;
  36. }
  37. int cnt=;
  38. for(int i=;i<=n;++i)
  39. if(a[i].id){
  40. b[++cnt]=a[i];
  41. for(int j=;j<=k;++j){
  42. b[cnt].sum+=max(,b[cnt].score[j]);
  43. if(b[cnt].score[j]==total[j])
  44. ++b[cnt].num;
  45. }
  46. }
  47. sort(b+,b++cnt,cmp);
  48. int rank_=;
  49. b[].sum=1e9;
  50. for(int i=;i<=cnt;++i){
  51. if(b[i].sum<b[i-].sum)
  52. rank_=i;
  53. printf("%d %05d %d",rank_,b[i].id,b[i].sum);
  54. for(int j=;j<=k;++j)
  55. if(b[i].score[j]==-)
  56. printf(" -");
  57. else
  58. printf(" %d",b[i].score[j]);
  59. printf("\n");
  60. }
  61. return ;
  62. }

【PAT甲级】1075 PAT Judge (25 分)的更多相关文章

  1. PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)

    1075 PAT Judge (25分)   The ranklist of PAT is generated from the status list, which shows the scores ...

  2. 【PAT甲级】1070 Mooncake (25 分)(贪心水中水)

    题意: 输入两个正整数N和M(存疑M是否为整数,N<=1000,M<=500)表示月饼的种数和市场对于月饼的最大需求,接着输入N个正整数表示某种月饼的库存,再输入N个正数表示某种月饼库存全 ...

  3. PAT 甲级 1020 Tree Traversals (25分)(后序中序链表建树,求层序)***重点复习

    1020 Tree Traversals (25分)   Suppose that all the keys in a binary tree are distinct positive intege ...

  4. PAT 甲级 1146 Topological Order (25 分)(拓扑较简单,保存入度数和出度的节点即可)

    1146 Topological Order (25 分)   This is a problem given in the Graduate Entrance Exam in 2018: Which ...

  5. PAT 甲级 1071 Speech Patterns (25 分)(map)

    1071 Speech Patterns (25 分)   People often have a preference among synonyms of the same word. For ex ...

  6. PAT 甲级 1063 Set Similarity (25 分) (新学,set的使用,printf 输出%,要%%)

    1063 Set Similarity (25 分)   Given two sets of integers, the similarity of the sets is defined to be ...

  7. PAT 甲级 1059 Prime Factors (25 分) ((新学)快速质因数分解,注意1=1)

    1059 Prime Factors (25 分)   Given any positive integer N, you are supposed to find all of its prime ...

  8. PAT 甲级 1051 Pop Sequence (25 分)(模拟栈,较简单)

    1051 Pop Sequence (25 分)   Given a stack which can keep M numbers at most. Push N numbers in the ord ...

  9. PAT 甲级 1048 Find Coins (25 分)(较简单,开个数组记录一下即可)

    1048 Find Coins (25 分)   Eva loves to collect coins from all over the universe, including some other ...

  10. PAT 甲级 1037 Magic Coupon (25 分) (较简单,贪心)

    1037 Magic Coupon (25 分)   The magic shop in Mars is offering some magic coupons. Each coupon has an ...

随机推荐

  1. An easy problem(位运算)

    As we known, data stored in the computers is in binary form.(数据以二进制形式存储于电脑之中.)The problem we discuss ...

  2. sql查询 —— 分页

    -- 分页 -- limit -- limit start count (start 显示骑士值,单页数量) select *from student where gender=1 limit 6,3 ...

  3. python3 yield实现假的多并发

    import time def fun1(): while True: print("fun1") time.sleep(0.1) yield def fun2(): while ...

  4. redis缓存处理机制

    1.redis缓存处理机制:先从缓存里面取,取不到去数据库里面取,然后丢入缓存中 例如:系统参数处理工具类 package com.ztesoft.iotcmp.utils; import com.e ...

  5. c数据结构 -- 栈与队列

    栈和队列 ·栈和队列是两种常用的.重要的数据结构 ·栈和队列是限定插入和删除只能在表的“端点”进行的线性表 栈 只能在队尾插入,只能在队尾删除 -- 后进后出 表尾称为栈顶:表头称为栈底 插入元素到栈 ...

  6. 如何转proto

    找到对应协议在对应proto中的片段(片段的子也要提取),提出来 放到适合proto文件中(逻辑 || 功能近似协议聚集地) 转换成proto.js 替换 || 增加原有js内容

  7. c# excel 读写 64位操作系统 64位excel

    用c#读写excel时,会出现 “本机未注册Microsoft.ACE.OLEDB.12.0 驱动(什么的,忘了)” 读写 64位的excel 时,要在项目属性里改一下目标平台,默认的为*86, 改为 ...

  8. Git的基本使用 -- 创建本地仓库

    下载安装 Git-2.25.0-64-bit .exe 查看是否安装成功 git --version 创建本地仓库 创建一个文件夹用于存放项目文件 在创建好的文件中右键选择 Git Bash Here ...

  9. Bugku-web进阶之phpcmsV9(一个靶机而已,别搞破坏。flag在根目录里txt文件里)

    phpcmsV9 一个靶机而已,别搞破坏. flag在根目录里txt文件里 http://123.206.87.240:8001/    

  10. Servlet转发

    可以使用ServletContext中的getRequestDispatcher(url).forward(request, response)方法进行转发 myservlet2.java publi ...