题意:

输入三个正整数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 分)的更多相关文章

  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. Unity中引入Supersocket.ClientEngine并测试

    在使用Supersocket Server的过程中,发现Server是不支持.net 3.5的. 1.Server端中的几个Command: namespace SuperSocketProtoSer ...

  2. 使用imread()函数读取图片的六种正确姿势

    OpenCV实践之路——使用imread()函数读取图片的六种正确姿势 opencv里的argv[1]指向的文件在哪里 测试 #include "opencv2/highgui/highgu ...

  3. FLAG-回归C++,JAVA什么的等学校教吧

    以后刷OJ还是写C++,昂啊! 除非我觉得JAVA更好用

  4. Java-POJ1010-STAMP

    说良心话,题目不难,但是题目真的很不好懂,解读一下吧 题意: 读入分两行,第一行为邮票面额(面额相同也视为种类不同)以0结束,第二行为顾客要求的面额,以0结束 要求:每个顾客最多拿4张邮票,并求最优解 ...

  5. wamp配置本地多站点。

    ' 进入C:\wamp64\wamp64\bin\apache\apache2.4.37\conf\http.conf 首先确保httpd-vhosts.conf扩展文件引入进来了,部分版本默认是不引 ...

  6. Jarvis OJ - 爬楼梯 -Writeup

    Jarvis OJ - 爬楼梯 -Writeup 本来是想逆一下算法的,后来在学长的指导下发现可以直接修改关键函数,这个题做完有种四两拨千斤的感觉,记录在这里 转载请标明出处:http://www.c ...

  7. 【转载】Java的JDBC事务详解

    转自:http://www.cnblogs.com/azhqiang/p/4044127.html 事务的特性: 1) 原子性(atomicity):事务是数据库的逻辑工作单位,而且是必须是原子工作单 ...

  8. 剑指Offer:面试题20:表示数值的字符串

    记录一下书上的写法.很整洁,每个函数的功能都显而易见.自己开始写的一堆if else语句像是一坨屎.另外注释的地方短路效应也要注意一下.总之这题还挺考察代码素质的(我这种就不存在什么素质..乱糟糟一团 ...

  9. arcgis中的Join(合并连接)和Relate(关联连接)

    arcgis中的Join(合并连接)和Relate(关联连接) 一.区别 1.连接关系不一样. Relate(关联连接)方式连接的两个表之间的记录可以是“一对一”.“多对一”.“一对多”的关系 Joi ...

  10. java把带小数点的字符串转换成int类型

    String number ="1.0000"; int num =Double.valueOf(number).intValue();//转换为Int类型