【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 ...
随机推荐
- SpringMVC请求乱码问题
今天做一个项目实现插入数据的功能,最开始没有添加FilterEncoding处理字符集乱码了,那是正常的,后来我添加过之后依然还是乱码,让我 百思不得其解,代码配置如下: EncodingFilter ...
- 在多租户(容器)数据库中如何创建PDB:方法1 从种子创建PDB
基于版本:19c (12.2.0.3) AskScuti 创建方法:从零开始创建一个PDB(从PDB$SEED创建新的PDB) 对应路径:Creating a PDB --> Creating ...
- json_encode中文不转义问题
//php5.3之后才有这个参数,这样存入数据库中的中文json数据就不会转义,也能被正确解析1JSON_UNESCAPED_UNICODE(中文不转为unicode ,对应的数字 256) JSON ...
- 140. 单词拆分 II
Q: 给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,在字符串中增加空格来构建一个句子,使得句子中所有的单词都在词典中.返回所有这些可能的句子. 说明: 分隔时可以重复使用字典 ...
- Java接收前台传回的json
var list = new Array(); var obj = {}; obj.name= "zhangsan"; obj.sex= "女";obj.ema ...
- OWIN时遇到的问题
1.在需要授权时如何获得需要授权的应用clientId? 除了从Request.QueryString("client_id")中获得还有别的方法吗?例如通过OWIN中间件的某个属 ...
- IDEA常用操作链接
idea中svn的提交.更新等操作 https://jingyan.baidu.com/article/375c8e19e3c47a25f3a22955.html Idea 部署SVN详细步骤以及上传 ...
- 第三十篇 玩转数据结构——字典树(Trie)
1.. Trie通常被称为"字典树"或"前缀树" Trie的形象化描述如下图: Trie的优势和适用场景 2.. 实现Trie 实现Trie的业务无 ...
- windows10打开switchHost,提示无修改权限
1.在C盘找到hsot文件,点击属性,去掉只读,去掉勾选. 点击编辑 点击Users,选择完全控制,这回降低电脑安全! 确定.
- 同步异步IO,阻塞非阻塞
同步异步 同步IO操作:导致请求进程阻塞,知道IO操作完成. 异步IO操作:不导致进程阻塞. 在处理(网络) IO 的时候,阻塞和非阻塞都是同步IO, 阻塞,就是调用我(函数),我(函数)没有接收完数 ...