【PAT甲级】1075 PAT Judge (25 分)
题意:
输入三个正整数N,K,M(N<=10000,K<=5,M<=100000),接着输入一行K个正整数表示该题满分,接着输入M行数据,每行包括学生的ID(五位整数1~N),题号和该题得分(-1表示没通过编译)。输出排名,学生ID,总分和每一题的得分,第一优先为总分降序,第二优先为题目AC数降序,第三优先为学生ID升序(提交但未通过编译得分为0,未提交得分为-,不输出没有提交或者提交全都未通过编译的学生信息)。
trick:
测试点4为有学生先交了得到分的程序后该题后来又交了未通过编译的程序,注意分支结构不要出错。
AAAAAccepted code:
- #define HAVE_STRUCT_TIMESPEC
- #include<bits/stdc++.h>
- using namespace std;
- typedef struct student{
- int id;
- int score[];
- int sum;
- int num;
- };
- student a[],b[];
- int total[];
- bool cmp(student x,student y){
- if(x.sum!=y.sum)
- return x.sum>y.sum;
- if(x.num!=y.num)
- return x.num>y.num;
- return x.id<y.id;
- }
- int main(){
- int n,k,m;
- scanf("%d%d%d",&n,&k,&m);
- for(int i=;i<=n;++i)
- for(int j=;j<=k;++j)
- a[i].score[j]=-;
- for(int i=;i<=k;++i)
- scanf("%d",&total[i]);
- for(int i=;i<=m;++i){
- int id,num,val;
- scanf("%d%d%d",&id,&num,&val);
- if(val>-)
- a[id].id=id;
- else if(a[id].score[num]<)
- a[id].score[num]=;
- if(val>a[id].score[num])
- a[id].score[num]=val;
- }
- int cnt=;
- for(int i=;i<=n;++i)
- if(a[i].id){
- b[++cnt]=a[i];
- for(int j=;j<=k;++j){
- b[cnt].sum+=max(,b[cnt].score[j]);
- if(b[cnt].score[j]==total[j])
- ++b[cnt].num;
- }
- }
- sort(b+,b++cnt,cmp);
- int rank_=;
- b[].sum=1e9;
- for(int i=;i<=cnt;++i){
- if(b[i].sum<b[i-].sum)
- rank_=i;
- printf("%d %05d %d",rank_,b[i].id,b[i].sum);
- for(int j=;j<=k;++j)
- if(b[i].score[j]==-)
- printf(" -");
- else
- printf(" %d",b[i].score[j]);
- printf("\n");
- }
- return ;
- }
【PAT甲级】1075 PAT Judge (25 分)的更多相关文章
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- 【PAT甲级】1070 Mooncake (25 分)(贪心水中水)
题意: 输入两个正整数N和M(存疑M是否为整数,N<=1000,M<=500)表示月饼的种数和市场对于月饼的最大需求,接着输入N个正整数表示某种月饼的库存,再输入N个正数表示某种月饼库存全 ...
- PAT 甲级 1020 Tree Traversals (25分)(后序中序链表建树,求层序)***重点复习
1020 Tree Traversals (25分) Suppose that all the keys in a binary tree are distinct positive intege ...
- PAT 甲级 1146 Topological Order (25 分)(拓扑较简单,保存入度数和出度的节点即可)
1146 Topological Order (25 分) This is a problem given in the Graduate Entrance Exam in 2018: Which ...
- PAT 甲级 1071 Speech Patterns (25 分)(map)
1071 Speech Patterns (25 分) People often have a preference among synonyms of the same word. For ex ...
- 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 ...
- 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 ...
- 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 ...
- PAT 甲级 1048 Find Coins (25 分)(较简单,开个数组记录一下即可)
1048 Find Coins (25 分) Eva loves to collect coins from all over the universe, including some other ...
- PAT 甲级 1037 Magic Coupon (25 分) (较简单,贪心)
1037 Magic Coupon (25 分) The magic shop in Mars is offering some magic coupons. Each coupon has an ...
随机推荐
- An easy problem(位运算)
As we known, data stored in the computers is in binary form.(数据以二进制形式存储于电脑之中.)The problem we discuss ...
- sql查询 —— 分页
-- 分页 -- limit -- limit start count (start 显示骑士值,单页数量) select *from student where gender=1 limit 6,3 ...
- python3 yield实现假的多并发
import time def fun1(): while True: print("fun1") time.sleep(0.1) yield def fun2(): while ...
- redis缓存处理机制
1.redis缓存处理机制:先从缓存里面取,取不到去数据库里面取,然后丢入缓存中 例如:系统参数处理工具类 package com.ztesoft.iotcmp.utils; import com.e ...
- c数据结构 -- 栈与队列
栈和队列 ·栈和队列是两种常用的.重要的数据结构 ·栈和队列是限定插入和删除只能在表的“端点”进行的线性表 栈 只能在队尾插入,只能在队尾删除 -- 后进后出 表尾称为栈顶:表头称为栈底 插入元素到栈 ...
- 如何转proto
找到对应协议在对应proto中的片段(片段的子也要提取),提出来 放到适合proto文件中(逻辑 || 功能近似协议聚集地) 转换成proto.js 替换 || 增加原有js内容
- c# excel 读写 64位操作系统 64位excel
用c#读写excel时,会出现 “本机未注册Microsoft.ACE.OLEDB.12.0 驱动(什么的,忘了)” 读写 64位的excel 时,要在项目属性里改一下目标平台,默认的为*86, 改为 ...
- Git的基本使用 -- 创建本地仓库
下载安装 Git-2.25.0-64-bit .exe 查看是否安装成功 git --version 创建本地仓库 创建一个文件夹用于存放项目文件 在创建好的文件中右键选择 Git Bash Here ...
- Bugku-web进阶之phpcmsV9(一个靶机而已,别搞破坏。flag在根目录里txt文件里)
phpcmsV9 一个靶机而已,别搞破坏. flag在根目录里txt文件里 http://123.206.87.240:8001/
- Servlet转发
可以使用ServletContext中的getRequestDispatcher(url).forward(request, response)方法进行转发 myservlet2.java publi ...