题意:

输入三个正整数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. StreamPipes

    MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was desi ...

  2. SpringCloud大白话之服务注册中心

    SpringCloud-Eureka白话说明 eureka.client.register-with-eureka 属性表示是否将自己注册到Eureka Server, 默认为true. 由于当前应用 ...

  3. goto语句的本质

    除非跳出多个循环嵌套和远程注入技术,否则尽量少用goto goto会降低程序的可读性,让代码难以调试 利用递归也可以实现循环结构和do while类似 #define _CRT_SECURE_NO_W ...

  4. c数据结构 -- 栈与队列

    栈和队列 ·栈和队列是两种常用的.重要的数据结构 ·栈和队列是限定插入和删除只能在表的“端点”进行的线性表 栈 只能在队尾插入,只能在队尾删除 -- 后进后出 表尾称为栈顶:表头称为栈底 插入元素到栈 ...

  5. crowdfunding项目01——感人的错误

    四十搭环境,半个小时下载jar包,网速感人,一个半小时找bug真是感动 首先SSM项目,主要功能进行增删改查 建立父工程和子工程,产生依赖关系 父工程:pom 子工程:jar.war(web工程) 错 ...

  6. (ghrd)pio设置

    设置中是下降沿,边沿触发.

  7. java的jdk和jre区别

    本文是本人随便总结的== 首先大概清楚个关系:jdk 包含 jre 包含 jvm 然后来看下,当我们配置完java运行环境的时候,是不是在java默认安装文件下发现jdk和jre两个包,然后jdk包里 ...

  8. jvm(1):内存结构

    JVM内存结构 JVM内存的运行时数据区: 线程私有(在线程启动时创建) 程序计数器Program Counter Register 一块较小的内存空间,可以看作是当前线程所执行的字节码的行号指示器, ...

  9. listView有感

    listView显示出来框,设置的是裁切后显示出来的界面,而非能装入item的空间.

  10. 「模板」Splay

    代码说明 对于一些变量进行说明: 变量名 说明 rt 树根 ff[u] 点 \(u\) 的父节点,特别地, ff[rt]=0 ch[u][0|1] 点 \(u\) 的 左/右儿子 siz[u] 点 \ ...