相当于是模拟OJ评测,这里注意最后输出:
1.那些所有提交结果都是-1的(即均未通过编译器的),或者从没有一次提交过的用户,不需要输出。
2.提交结果为-1的题目,最后输出分数是0
3.某个题目从没有提交过的,输出'-'

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <queue>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=+;
int problem[]; struct User{
int id;
int score=;
int problem[]={-,-,-,-,-,-};
int submitted[]={,,,,,}; //标记题目是否有提交,没提交的对应的就要输出'-'
int perfect=; //拿满分的题目个数
int ranks=INF;
int isShow=; //用于标记是否要输出,即用户只要有一题通过编译器,不管是否为0,设置为1.
bool operator<(const User tmp)const{
if(ranks==tmp.ranks){
if(perfect==tmp.perfect){
return id<tmp.id;
}
else{
return perfect>tmp.perfect;
}
}
else{
return ranks<tmp.ranks;
}
}
}user[maxn]; bool cmp1(User a, User b){
return a.score>b.score;
} bool cmp2(User a,User b){
if(a.ranks==b.ranks){
if(a.perfect==b.perfect){
return a.id<b.id;
}
else{
return a.perfect>b.perfect;
}
}
else{
return a.ranks<b.ranks;
}
} int main()
{
int N,K,M;
int id,pid,score;
scanf("%d %d %d",&N,&K,&M);
for(int i=;i<=K;i++){
scanf("%d",&problem[i]);
}
for(int i=;i<M;i++){
scanf("%d %d %d",&id,&pid,&score);
user[id].id=id;
user[id].problem[pid]=max(user[id].problem[pid],score);
user[id].submitted[pid]=;
//if(score==problem[pid])
// user[id].perfect++; //不能这里就统计拿满分的题目个数,因为可能存在多次提交
if(score!=-)
user[id].isShow=;
}
for(int i=;i<=N;i++){
for(int j=;j<=K;j++){
if(user[i].problem[j]!=-)
user[i].score+=user[i].problem[j];
if(user[i].problem[j]==problem[j])
user[i].perfect++;
}
}
sort(user+,user+N+,cmp1); int cnt=;
int lastid=;
user[].ranks=cnt;
user[].score=-;
for(int i=;i<=N;i++){
user[i].ranks=i;
if(i!= && user[i].score==user[i-].score)
user[i].ranks=user[i-].ranks;
}
sort(user+,user+N+,cmp2);
for(int i=;i<=N;i++){
if(user[i].isShow==)
continue;
printf("%d %05d %d",user[i].ranks,user[i].id,user[i].score);
for(int j=;j<=K;j++){
if(user[i].submitted[j]==){
printf(" -");
}
else{
if(user[i].problem[j]!=-)
printf(" %d",user[i].problem[j]);
else
printf("");
}
}
printf("\n");
}
return ;
}

PAT甲题题解-1075. PAT Judge (25)-排序的更多相关文章

  1. PAT甲题题解-1129. Recommendation System (25)-排序

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789819.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  2. PAT甲题题解-1051. Pop Sequence (25)-堆栈

    将1~n压入最多为m元素的栈 给出k个出栈序列,问你是否能够实现. 能输出YES 否则NO 模拟一遍即可,水题. #include <iostream> #include <cstd ...

  3. PAT甲题题解-1059. Prime Factors (25)-素数筛选法

    用素数筛选法即可. 范围long int,其实大小范围和int一样,一开始以为是指long long,想这就麻烦了该怎么弄. 而现在其实就是int的范围,那难度档次就不一样了,瞬间变成水题一枚,因为i ...

  4. PAT甲题题解-1101. Quick Sort (25)-大水题

    快速排序有一个特点,就是在排序过程中,我们会从序列找一个pivot,它前面的都小于它,它后面的都大于它.题目给你n个数的序列,让你找出适合这个序列的pivot有多少个并且输出来. 大水题,正循环和倒着 ...

  5. PAT甲题题解-1117. Eddington Number(25)-(大么个大水题~)

    如题,大水题...贴个代码完事,就这么任性~~ #include <iostream> #include <cstdio> #include <algorithm> ...

  6. PAT甲题题解-1130. Infix Expression (25)-中序遍历

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789828.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  7. PAT甲题题解-1016. Phone Bills (25)-模拟、排序

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789229.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  8. PAT甲题题解-1021. Deepest Root (25)-dfs+并查集

    dfs求最大层数并查集求连通个数 #include <iostream> #include <cstdio> #include <algorithm> #inclu ...

  9. PAT甲题题解-1024. Palindromic Number (25)-大数运算

    大数据加法给一个数num和最大迭代数k每次num=num+num的倒序,判断此时的num是否是回文数字,是则输出此时的数字和迭代次数如果k次结束还没找到回文数字,输出此时的数字和k 如果num一开始是 ...

随机推荐

  1. 深入浅出SharePoint——Search疑难排除

    通过Search log http://richardstk.com/2013/12/23/using-the-sharepoint-2013-search-query-tool-with-searc ...

  2. openlayer3 基础学习一创建&显示地图

    <!doctype html> <html lang="en"> <head> <link rel="stylesheet&qu ...

  3. facebook api & oauth protocal

    http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-10.5 http://stackoverflow.com/questions/14 ...

  4. [BUG]自己的bug自己解,记一次在变量使用过程引发的bug

    [实现的功能要求]在短信编辑界面,将所有的emoji表情全部插入到编辑区域,其中表情共有5页,每遍历完一页时需要自动翻页重新获取表情并插入,在第5页中只有10个表情 下面先看看这段代码,大家能否看出有 ...

  5. JS中的防抖与节流

    什么是防抖?and什么是节流?一起来开心的学习下吧. 首先什么是防抖:就是在一定的时间内事件只发生一次,比如你点击button按钮,1秒内任你单身30年手速点击无数次,他也还是只触发一次.举个例子,当 ...

  6. loli的搜索测试-我真不知道是第多少次了

    搜索测试 又到了....并不激动人心的搜索测试时间. 今天和以前还是有一点不一样的,新高二的学长们也参加了(也就是说我们又要被吊打了) 话不多说,看题: fz:填一个5*5的质数方阵,要求每行,每列, ...

  7. AddHandler php5-script .php\AddType text/html .php和AddType application/x-httpd-php .php的区别?

    让apache支持php文件的解释,有2种方法配置,RPM装的默认配置是:AddHandler php5-script .phpAddType text/html .php网上很多人的配置方法是:Ad ...

  8. helm 部署

    Helm 基本概念 Helm 可以理解为 Kubernetes 的包管理工具,可以方便地发现.共享和使用为Kubernetes构建的应用,它包含几个基本概念 Chart:一个 Helm 包,其中包含了 ...

  9. CentOS常用命令备忘

    1. 查看进程 ps -a 杀掉进程 kill PID 2. 添加计划任务crontab -e 例如:30 21 * * * service httpd restart 每天21:30重启apache ...

  10. 无法找到“XXX.exe”的调试信息,或者调试信息不匹配。未使用调试信息生成二进制文件

    1.问题症状 已经处于Debug模式,运行时完全正常,但是一调试就出现对话框,显示出错信息:“无法找到“XXX.exe”的调试信息,或者调试信息不匹配.未使用调试信息生成二进制文件.” 2.解决方法 ...