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循环,根据字 ...
随机推荐
- 第二个C语言代码
有问题,还没找出哪里出错了 输入一串字符,问号结束 统计1~9各出现的次数 ******************************************************** ...
- Razor视图引擎的基本概念与法语
Razor 视图引擎的特点: 简洁.富于表现.流畅 尽量减少页面代码的输入,实现快速流畅的编程工作 不必明确为服务器代码标记起始与结束符,Razor 能智能判断,这样让页面看清洁,代码方便阅读 asp ...
- 关于 hot code replace fail 问题 .
频频出现Hot code replace failed问题.网上查不到解决方法,想来想去,是否是jvm的问题?我的jre使用自己下载的jdk1.6.07,而MyEclipse的jvm自带的是1.5.0 ...
- Fisher's exact test( 费希尔精确检验)
Fisher's exact test[1][2][3] is a statistical significance test used in the analysis ofcontingency t ...
- 类似百度文库pdf2swf+flexpaper解决pdf在线阅读的效果
1:工具准备swftools.exe 下载http://www.swftools.org/download.html 安装至D盘SWFTools提供了一系列将各种文件转成swf的工具:font2swf ...
- thinkphp框架 中 ajax 的应用
在thinkphp中,内置了ajax的方法,即: ajaxReturn("data","info","status"); data:传递的数 ...
- Angularjs checkbox的ng属性
angularjs 默认给 input[checkbox] 元素定制了一些属性,如: <input type="checkbox" ng-mudel="name&q ...
- Maven、gradle、Ant、Eclipse IDE
Maven.gradle.Ant.Eclipse IDE之间的关系 http://wenku.baidu.com/view/d33208810912a21615792910.html?from=sea ...
- poj2192
初看这道题,以为是先用SA和SC求LCS,再从SC中把SA剔除,看剩下来的是不是SB(……) 显然不对;因为SC与SA的公共子串不止一种,判断不一定正确. 于是考虑SC中每一个字符,如果能够匹配,那么 ...
- Web打印控件smsx.cab使用说明
在项目开发中,经常会用到页面打印的功能,在ASP.NET环境下推荐一款web打印控件smsx.cab. 使用方法:一般会先定义一个用于打印的母版页(Print.Master),在母版页上做好布局 ...