/*
* 1.主要就用了个sort对结构体的三级排序
*/ #include "iostream"
#include "algorithm"
using namespace std;
int perfectScore[];
struct Node {
int id;
int score[] = {-,-,-,-,-,-}; /* 记录每一题的分数 初始化为-2代表没答题 */
int totalScore = ; /* 记录总分 */
int perfectSolvedNum = ; /* 记录得满分的题目总数 */
bool flag = false; /* 判断该用户能否上ranklist 默认不能 */
}stu[];
int comp(const Node &stu1, const Node &stu2) {
if (stu1.totalScore == stu2.totalScore) {
if (stu1.perfectSolvedNum == stu2.perfectSolvedNum)
return stu1.id < stu2.id;
else
return stu1.perfectSolvedNum > stu2.perfectSolvedNum;
}
else
return stu1.totalScore > stu2.totalScore;
}
void getMSG(Node stu[],int n,int k) {
for (int i = ; i <= n; i++) {
for (int j = ; j <= k; j++) {
if(stu[i].score[j]>=)
stu[i].totalScore += stu[i].score[j];
if (stu[i].score[j] >= )
stu[i].flag = true;
if (stu[i].score[j] == -)
stu[i].score[j] = ;
if (stu[i].score[j] == perfectScore[j])
stu[i].perfectSolvedNum += ;
}
}
}
int main() {
int n, m, k;
cin >> n >> k >> m;
for (int i = ; i <= k; i++)
cin >> perfectScore[i];
while (m--) {
int stuId, proId, score;
cin >> stuId >> proId >> score;
stu[stuId].id = stuId;
if (score > stu[stuId].score[proId])
stu[stuId].score[proId] = score;
}
getMSG(stu, n, k);
sort(stu+,stu+n+,comp);
int l = ;
int temp = stu[].totalScore;
int rank = ;
for (int i = ; i <= n; i++) {
if (stu[i].flag) {
if (stu[i].totalScore == temp)
l++;
else {
rank += l;
l = ;
temp = stu[i].totalScore;
}
cout << rank << " ";
printf("%05d ", stu[i].id);
cout << stu[i].totalScore;
for (int j = ; j <= k; j++) {
if (stu[i].score[j] == -)
cout << " -";
else
cout << " " << stu[i].score[j];
}
cout << endl;
}
}
return ;
}

PTA 5-15 PAT Judge (25分)的更多相关文章

  1. PTA 10-排序5 PAT Judge (25分)

    题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/677 5-15 PAT Judge   (25分) The ranklist of PA ...

  2. PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)

    1075 PAT Judge (25分)   The ranklist of PAT is generated from the status list, which shows the scores ...

  3. PATA1075 PAT Judge (25 分)

    The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...

  4. 10-排序5 PAT Judge (25 分)

    The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...

  5. A1075 PAT Judge (25 分)

    The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...

  6. 【PAT甲级】1075 PAT Judge (25 分)

    题意: 输入三个正整数N,K,M(N<=10000,K<=5,M<=100000),接着输入一行K个正整数表示该题满分,接着输入M行数据,每行包括学生的ID(五位整数1~N),题号和 ...

  7. A1075 PAT Judge (25)(25 分)

    A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...

  8. PTA 7-3 Windows消息队列 (25分)

    PTA 7-3 Windows消息队列 (25分) 消息队列是Windows系统的基础.对于每个进程,系统维护一个消息队列.如果在进程中有特定事件发生,如点击鼠标.文字改变等,系统将把这个消息加到队列 ...

  9. 1040 有几个PAT (25 分)

    题目链接:1040 有几个PAT (25 分) 做这道题目,遇到了新的困难.解决之后有了新的收获,甚是欣喜! 刚开始我用三个vector数组存储P A T三个字符出现的位置,然后三层for循环,根据字 ...

随机推荐

  1. IOS - IOS之同步请求、异步请求、GET请求、POST请求

    1.同步请求可以从因特网请求数据,一旦发送同步请求,程序将停止用户交互,直至服务器返回数据完成,才可以进行下一步操作, 2.异步请求不会阻塞主线程,而会建立一个新的线程来操作,用户发出异步请求后,依然 ...

  2. 利用CodeIgniter中的Email类发邮件

    CodeIgniter拥有功能强大的Email类.以下为利用其发送邮件的代码. 关于CI的Email类的详情请参考:http://codeigniter.org.cn/user_guide/libra ...

  3. Linux下修改PATH的方法

    Linux下修改PATH的方法 1.直接在命令行里敲 PATH=$PATH:/path1:/path2:/pathN用户登出之后PATH恢复原样. 只是临时起作用. 2.修改~目录下bash_prof ...

  4. 1316. Electronic Auction(树状数组)

    1316 我想说 要不要这么坑 WA了一个小时啊 ,都快交疯了,拿着题解的代码交都WA 最后很无语的觉得题解都错了 重读了N遍题意 发现没读错啊 难道写题解的那个人和我都想错了?? 最后把g++换个C ...

  5. Repeater的ItemCommand事件(LinkButton)

    Repeater的ItemCommand事件,就是在里面加一个超链接的按钮,所有按钮都指向同一个事件,就是ItemCommand事件. 至于如何区分是点击的什么按钮,还有传的值,需要用到LinkBut ...

  6. Dubbo实例

    1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.简单的说,dubbo就是个服务框架,如果没有分布式的需求,其实是不需 ...

  7. varchar与nvarchar的区别

    nvarchar可变长度的Unicode字符数据 varchar可变长度且非 Unicode 的字符数据 举例: varchar(1)   --可以插进入一个数字或者一个字母,如果要插入一个汉字改为v ...

  8. 【转】angular Ajax请求

    1.http请求 基本的操作由 $http 服务提供.它的使用很简单,提供一些描述请求的参数,请求就出去了,然后返回一个扩充了 success 方法和 error 方法的 promise对象(下节介绍 ...

  9. 【Web前沿技术】纯 CSS3 打造的10个精美加载进度条动画

    之前向大家介绍8款优秀的 jQuery 加载动画和进度条插件,今天这篇文章向大家推荐10个纯 CSS3 代码实现精美加载进度条动画效果的方案.加载动画和进度条在网站和 Web 应用中的使用非常流行,特 ...

  10. [GRYZ2015]足球联赛

    问题描述 巴蜀中学新一季的足球联赛开幕了.足球联赛有n 只球队参赛,每赛季,每只球队要与其他球队各赛两场,主客各一场,赢一场得3 分,输一场不得分,平局两只队伍各得一分.英勇无畏的小鸿是机房的主力前锋 ...