To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - English. At the mean time, we encourage students by emphasizing on their best ranks -- that is, among the four ranks with respect to the three courses and the average grade, we print the best rank for each student.

For example, The grades of CME and A - Average of 4 students are given as the following:

StudentID  C  M  E  A
310101 98 85 88 90
310102 70 95 88 84
310103 82 87 94 88
310104 91 91 91 91

Then the best ranks for all the students are No.1 since the 1st one has done the best in C Programming Language, while the 2nd one in Mathematics, the 3rd one in English, and the last one in average.

Input Specification:

Each input file contains one test case. Each case starts with a line containing 2 numbers N and M (≤), which are the total number of students, and the number of students who would check their ranks, respectively. Then N lines follow, each contains a student ID which is a string of 6 digits, followed by the three integer grades (in the range of [0, 100]) of that student in the order of CM and E. Then there are M lines, each containing a student ID.

Output Specification:

For each of the M students, print in one line the best rank for him/her, and the symbol of the corresponding rank, separated by a space.

The priorities of the ranking methods are ordered as A > C > M > E. Hence if there are two or more ways for a student to obtain the same best rank, output the one with the highest priority.

If a student is not on the grading list, simply output N/A.

Sample Input:

5 6
310101 98 85 88
310102 70 95 88
310103 82 87 94
310104 91 91 91
310105 85 90 90
310101
310102
310103
310104
310105
999999

Sample Output:

1 C
1 M
1 E
1 A
3 A
N/A

完了,英文不好会死人呀,看了别人的解释才知道,是找出每个学生在A,C,M,E中的最好排名
如果在A、C、M、E排序过程中遇到同样的分数,需要有相同的排名,
比如在A这一科上5个人的成绩分别是100,90,90,88,87的话,排名应该是1,2,2,4,5,
这一点需要格外留意,不然没有办法通过所有测试。

 #include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std; struct Data
{
string No;
int num;
int rank;
}; int main()
{
int N, M;
cin >> N >> M;
vector<Data>nums[];//A C M E
unordered_map <string, int>name;//用于学号查找
for (int i = ; i < N; ++i)
{
string No;
int c, m, e;
cin >> No >> c >> m >> e;
name[No]++;
nums[].push_back({ No,(c + m + e) / , });
nums[].push_back({ No,c, });
nums[].push_back({ No,m, });
nums[].push_back({ No,e, });
}
for (int i = ; i < ; ++i)
{
sort(nums[i].begin(), nums[i].end(), [](Data d1, Data d2) {return d1.num > d2.num; });
for (int j = ; j < nums[i].size(); ++j)
{
if (nums[i][j].num == nums[i][j - ].num)//处理相同分数
nums[i][j].rank = nums[i][j - ].rank;
else
nums[i][j].rank = j + ;//要跳过相同排名
}
} for (int j = ; j < M; ++j)
{
string No;
cin >> No;
int a, c, m, e;
if (name[No] == )
cout << "N/A" << endl;
else
{
for (int i = ; i < name.size(); ++i)
{
if (nums[][i].No == No) a = nums[][i].rank;
if (nums[][i].No == No) c = nums[][i].rank;
if (nums[][i].No == No) m = nums[][i].rank;
if (nums[][i].No == No) e = nums[][i].rank;
}
if (a <= c && a <= m && a <= e) cout << a << " " << "A" << endl;
else if (c <= a && c <= m && c <= e) cout << c << " " << "C" << endl;
else if (m <= a && m <= c && m <= e) cout << m << " " << "M" << endl;
else cout << e << " " << "E" << endl;
}
}
return ;
}

PAT甲级——A1012 The Best Rank的更多相关文章

  1. PAT甲级1012. The Best Rank

    PAT甲级1012. The Best Rank 题意: 为了评估我们第一年的CS专业学生的表现,我们只考虑他们的三个课程的成绩:C - C编程语言,M - 数学(微积分或线性代数)和E - 英语.同 ...

  2. PAT 甲级 1012 The Best Rank

    https://pintia.cn/problem-sets/994805342720868352/problems/994805502658068480 To evaluate the perfor ...

  3. PAT 甲级 1012 The Best Rank (25 分)(结构体排序)

    题意: 为了评估我们第一年的CS专业学生的表现,我们只考虑他们的三个课程的成绩:C - C编程语言,M - 数学(微积分或线性代数)和E - 英语.同时,我们鼓励学生强调自己的最优秀队伍 - 也就是说 ...

  4. PAT甲级——1012 The Best Rank

    PATA1012 The Best Rank To evaluate the performance of our first year CS majored students, we conside ...

  5. PAT甲级题解(慢慢刷中)

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

  6. A1012 The Best Rank (25)(25 分)

    A1012 The Best Rank (25)(25 分) To evaluate the performance of our first year CS majored students, we ...

  7. 【转载】【PAT】PAT甲级题型分类整理

    最短路径 Emergency (25)-PAT甲级真题(Dijkstra算法) Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) Travel P ...

  8. PAT甲级题分类汇编——排序

    本文为PAT甲级分类汇编系列文章. 排序题,就是以排序算法为主的题.纯排序,用 std::sort 就能解决的那种,20分都算不上,只能放在乙级,甲级的排序题要么是排序的规则复杂,要么是排完序还要做点 ...

  9. PAT甲级1056Mice and Rice

    目录 题目介绍 题解 解题思路 代码 参考链接 题目介绍 题目链接 https://pintia.cn/problem-sets/994805342720868352/problems/9948054 ...

随机推荐

  1. JAVA 文件的上传下载

    一.上传文件 1.使用 transferTo 上传 @ResponseBody @RequestMapping(value = "/file/upload") public Res ...

  2. 引用第三方 chalk 模块

    第三方模块没有默认引用到我们的电脑中,我们要进行下载 chalk 这个包是为了使输出不再单调,添加文字背景什么的,改变字体颜色什么的, npm install chalk //只需要写文件包名,不需要 ...

  3. 在centos 6.9 x64下安装code::blocks步骤

    1.yum groupinstall "Development tools" 2.yum install gtk2* 3.安装wxWidgets 下载地址:https://www. ...

  4. CSS 继承和优先级

    CSS继承性 CSS属性继承:外层元素的样式,会被内层元素进行继承. 多个外层元素的样式,最终都会“叠加”到内层元素上. 什么样的CSS属性能被继承呢? CSS文本属性都会被继承的: color. f ...

  5. 最全的机器学习&深度学习入门视频课程集

    资源介绍 链接:http://pan.baidu.com/s/1kV6nWJP 密码:ryfd     链接:http://pan.baidu.com/s/1dEZWlP3 密码:y82m 更多资源 ...

  6. let能否完全替代IIFE

    let是什么 http://es6.ruanyifeng.com/#docs/let 最近,我写了一篇关于syntax of Java’s IIFE pattern的文章,来解释为什么我们用现在的方式 ...

  7. [课后作业] 第002讲:用Python设计第一个游戏 | 课后测试题

    试题: 0. 什么是BIF? 1. 用课堂上小甲鱼教的方法数一数 Python3 提供了多少个 BIF? 2. 在 Python 看来:'FishC' 和 'fishc' 一样吗? 3. 在小甲鱼看来 ...

  8. 如何将制定目录加入到PYTHONPATH

    1 问题背景 TensorFlow Object Detection API 是以Slim为基础实现的,需要将Slim的目录加入PYTHONPATH后才能正确运行. 2 机器环境 window10 a ...

  9. LVS/Nginx/HAProxy负载均衡器的对比分析

    转自:http://www.blogjava.net/ivanwan/archive/2013/12/25/408014.html LVS的特点是: 抗负载能力强.是工作在网络4层之上仅作分发之用,没 ...

  10. React require(“history”).createBrowserHistory` instead of `require(“history/createBrowserHistory”)

    看见bug惊讶,代码中并没有require("history/createBrowserHistory") //原有代码为 import createBrowserHistory ...