PTA 5-15 PAT Judge (25分)
/*
* 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分)的更多相关文章
- 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 ...
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- PATA1075 PAT Judge (25 分)
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...
- 10-排序5 PAT Judge (25 分)
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...
- A1075 PAT Judge (25 分)
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...
- 【PAT甲级】1075 PAT Judge (25 分)
题意: 输入三个正整数N,K,M(N<=10000,K<=5,M<=100000),接着输入一行K个正整数表示该题满分,接着输入M行数据,每行包括学生的ID(五位整数1~N),题号和 ...
- A1075 PAT Judge (25)(25 分)
A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...
- PTA 7-3 Windows消息队列 (25分)
PTA 7-3 Windows消息队列 (25分) 消息队列是Windows系统的基础.对于每个进程,系统维护一个消息队列.如果在进程中有特定事件发生,如点击鼠标.文字改变等,系统将把这个消息加到队列 ...
- 1040 有几个PAT (25 分)
题目链接:1040 有几个PAT (25 分) 做这道题目,遇到了新的困难.解决之后有了新的收获,甚是欣喜! 刚开始我用三个vector数组存储P A T三个字符出现的位置,然后三层for循环,根据字 ...
随机推荐
- linux下添加PATH环境变量
添加PATH环境变量,第1种方法:[root@lx_web_s1 ~]# export PATH=/usr/local/webserver/mysql/bin:$PATH 再次查看: [root@lx ...
- WinAPI——钩子函数大全3
函数原形:LRESULT CALLBACK JournalPlaybackProc(int code, WPARAM wParam, LPARAM lParam); 参数: code:指示一个代码,被 ...
- IMX515开发备忘
1.多个PAD可以选择为同样的功能引脚 IMX515处理器一个PAD可以作为多种功能引脚,比如EIM_D25可以作为UART3_RXD,定义如下: 图1 而处理还有一个另一个UART3_RXD的PAD ...
- 【HDOJ】4691 Front compression
后缀数组基础题目,dc3解. /* 4691 */ #include <iostream> #include <sstream> #include <string> ...
- notepad++ 编辑器链接地址可点击
很久没用notepad++编辑器,最近因为 sublime 的编码问题,因此用了下 notepad++ .结果发现里面的链接都可以点击,一点都不要编辑,如下图: 那如何把这个功能去掉呢? 我们选择 菜 ...
- [swustoj 1097] 2014
2014(1097) 问题描述 今年是2014年,所以小明喜欢2014的每一位数字(即:2,0,1,4),小明想知道在区间[l,r](包括l和r)中有多少个数中含有这4个数字(数字无前缀零). 输入 ...
- POJ 1149 PIGS ★(经典网络流构图)
[题意] 有M个猪圈,每个猪圈里初始时有若干头猪.一开始所有猪圈都是关闭的.依 次来了N个顾客,每个顾客分别会打开指定的几个猪圈,从中买若干头猪.每 个顾客分别都有他能够买的数量的上限.每个顾客走后, ...
- 【 D3.js 高级系列 — 4.0 】 矩阵树图
矩阵树图(Treemap),也是层级布局的扩展,根据数据将区域划分为矩形的集合.矩形的大小和颜色,都是数据的反映.许多门户网站都能见到类似图1,将照片以不同大小的矩形排列的情形,这正是矩阵树图的应用. ...
- Wiz开发 定时器的使用与处理
这只是一些代码片段,由于Wiz开发的资料实在不多,而且内容都不够新. 这里的代码主要参考Tools.Timer这个插件,但是由于内部实现的很多变化,Tools.Timer这个插件基本上已经无法使用了. ...
- Event事件详解
首先提到event,先要明白event的产生,也要先明白焦点,什么是焦点.焦点 : 使浏览器能够区分用户输入的对象,当一个元素有焦点的时候,那么他就可以接收用户的输入. 我们可以通过一些方式给元素设置 ...