【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 ...
随机推荐
- java多线程技术
如何实现线程 首先实现线程的两个方法:1.继承thread:2.实现接口Runnable类: 这边我就说一下第二种,因此第二种在开发中使用的比较多一些,能避免继承还是少避免继承. RunnableDe ...
- django--关于部署scrapyd项目报错问题
首先在同步两篇之前写过的博客,可能能用得到 1.https://www.cnblogs.com/lutt/p/10893192.html2.https://www.cnblogs.com/lutt/p ...
- 如何在Word中批量选中特定文本
如何在Word中批量选中特定文本 举个例子,我们对如下文本进行操作,将文本中所有的“1111111”标红,所有的“2222222”标绿,所有的“3333333”标蓝 在Word中找到“查找”下的“高级 ...
- jenkins集成robot
一.jenkins集成robot的非gui的运行命令 pybot 配置文件 用例地址 或者robot 配置文件 用例地址 二.展示robot 运行结果图表 1.在系统配置中增加Rob ...
- python面试的100题(5)
5.现有字典 d= {'a':24,'g':52,'i':12,'k':33}请按value值进行排序? sorted(d.items(),key=lambda x:x[1]) sorted函数 对由 ...
- beego orm 多对多插入和查询操作
// User 用户表 type User struct { ID int UserName string Password string Articles []*Article `orm:" ...
- requests.packages.urllib3.exceptions.ProxySchemeUnknown: Not supported proxy scheme
python3 -m pip install -U requests[socks]
- git中全局设置用户名、邮箱
1.查看git配置信息:git config --list (可以查看所有的配置信息) 2.查看git用户名:git config user.name 3.查看邮箱配置:git config user ...
- pycharm2019.3安装以及激活
最近很多的pycharm激活过期的,小伙伴们问我pycharm要怎么激活?这里就分享一下pycharm最新版本的安装以及激活吧!!! 首先先去官网(https://www.jetbrains.com/ ...
- 题解 P3951 小凯的疑惑
P3951 小凯的疑惑 数论极菜的小萌新我刚看这题时看不懂exgcd做法的题解,后来在网上找到了一篇博客,感觉代码和推导都更加清新易懂,于是在它的基础上写了题解qwq 分析 两数互质,且有无限个,想到 ...