【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 数组
声明 int[] arr = new int[5]; 在数组中插入数据 备注:i是插入的位置,i+1是实际位置 public static int[] insert(int[] arr,int i,i ...
- python pymysql 基本使用
from pymysql import * # 1.创建连接数据库 conn = connect(host="localhost", port=3306, user="r ...
- python lambda ,map详解
lambda 匿名函数 # 普通定义函数 def func1(x,y): return x+y # 执行函数 print(func(1,2)) # 如果此函数只调用一次,或者功能简单,此方法就显得笨拙 ...
- python3练习100题——014
这题卡了我一整天,然后还是看答案撸了一遍- 原题链接:http://www.runoob.com/python/python-exercise-example14.html 题目:将一个正整数分解质因 ...
- appium---webview(H5)元素定位
我们在做UI自动化的时候,肯定需要元素定位,那么webview(H5)的元素怎么定位呢? webview定位方法 方法一: 1.打开chrome浏览器,输入chrome://inspect 2.连接手 ...
- 第四十七篇 入门机器学习——分类的准确性(Accuracy)
No.1. 通常情况下,直接将训练得到的模型应用于真实环境中,可能会存在很多问题 No.2. 比较好的解决方法是,将原始数据中的大部分用于训练数据,而留出少部分数据用于测试,即,将数据集切分成训练数据 ...
- 密码学笔记-一段base64wp
CTF--练习平台 例题: 一段Base64 flag格式:flag{xxxxxxxxxxxxx} 附件: base64.txt 1.base64解码:http://base64.xpcha.com/ ...
- JS table新增一行的时候 如何在新增的这一行把样式也加进去 例如变成<tr class="trd0">
JS table新增一行的时候 如何在新增的这一行把样式也加进去 例如变成<tr class="trd0">5 JS: var tab = document.get ...
- HTML5学习(2)语义化
什么是语义化? 1.每一个HTML元素都有具体的含义,例: a元素:超链接,p元素:段落 2.所有的元素与展示效果无关 元素内容展示到页面中的效果,应该由CSS决定. 因为浏览器带有默认的CSS样式, ...
- MySQL对大小写敏感吗
见字如面,见标题知内容.你有遇到过因为MYSQL对大小写敏感而被坑的体验吗? 之前看过阿里巴巴Java开发手册,在MySql建表规约里有看到: [强制]表名.字段名必须使用小写字母或数字 , 禁止出现 ...