/*
* 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. ajax readyState的五种状态详解

    通过ajax的readyState的值,我们可以知道当前的这个http请求处于什么状态.对于web的调试是比较重要的. readyState 状态说明: (0)未初始化 此阶段确认XMLHttpReq ...

  2. Eclipse中查看Android模拟器SD卡目录

    · 有时候用到Android模拟器来模拟SD卡相关操作,在Eclipse中可以直接查看SD卡目录: 首先,新建模拟器的时候要创建SD卡,存储的大小根据需要创建: 启动模拟器,在Eclipse中打开视图 ...

  3. 深入php面向对象和模式

    前两章是php历史和概论,略过. 第三章 对象基础 3.1 类和对象 类,是用于生成对象的代码模版. public 公有的,都可调用. protected 保护的, 只有本类和子类可以调用. priv ...

  4. PL/SQL Developer使用技巧

    1.PL/SQL Developer记住登陆密码 在使用PL/SQL Developer时,为了工作方便希望PL/SQL Developer记住登录Oracle的用户名和密码: 设置方法:PL/SQL ...

  5. 2013ACM省赛题目

    地址就贴这一个吧 都在附近 当时回来也没做做 一伤心了 二是当时实在太弱了 先补两道DP E题的区间DP dp[i][j]  截止到i位置以字母j为结束的上升序列 正序 逆序各来一遍 再循环一遍保存一 ...

  6. poj3275

    比较笨啊,一直在想,到底问几次绝对能知道所有的关系呢? 后来看了题解才知道,问一次最少确定一对关系………… 这就好办le,n头牛有C(2,n)个关系 现在给出m条边,以确定的关系有多少呢?直接dfs啊 ...

  7. 漫长的补结题报告之路 poj3622

    题意(引用):题意:有很多种草,有两个属性:价格和新鲜度:有很多牛,它们都会各自需求一种草,要求是其价格最低为ai,新鲜度最低为bi,且这些牛不希望自己的草和别人的一样.问要满足所有需求的最小花费是多 ...

  8. CSS基础深入之细说盒子模型

    Html任何一个元素(element)都可以当成一个盒子(box)来看待,可以结合现实中的盒子来理解下文,下文其中一些单词应该是通俗易懂的需要记录的单词. 基本情况 每一个盒子都有一个内容区域(con ...

  9. Birt时间参数添加My97日历控件

    首先,思路: 引用My97.js然后为时间参数的textbox添加onclick事件 1.将My97添加到项目中的webcontent目录下(如图:) 2.添加My97引用 在项目路径下找到该文件\w ...

  10. shell判断条件是否存在

    1. shell判断文件,目录是否存在或者具有权限 2. #!/bin/sh 3. 4. myPath="/var/log/httpd/" 5. myFile="/var ...