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. System.Web.UI.WebControls.FileUpload.cs

    ylbtech-System.Web.UI.WebControls.FileUpload.cs 1. 程序集 System.Web, Version=4.0.0.0, Culture=neutral, ...

  2. 同步+TASK异步请求

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  3. Mac 上的 redis

    Mac下添加redis的环境变量: echo 'export PATH="/usr/local/opt/redis@3.2/bin:$PATH"' >> ~/.bash ...

  4. (转)线程池 ExecutorService 详细介绍以及注意点区别

    线程池 ExecutorService 相信java开发都用到,这里做个简单笔记 一 Java通过Executors提供四种线程池,分别为: newCachedThreadPool创建一个可缓存线程池 ...

  5. opencv编译:opencv 3.4.1 编译 contrib模块,增加人脸识别

    start cmake-gui select the opencv source code folder and the folder where binaries will be built (th ...

  6. axel 参数 文件下载地址

    axel 参数 文件下载地址 可选参数: -n 指定线程数 -o 指定另存为目录 -s 指定每秒的最大比特数 -q 静默模式 实例 axel -n 10 -o /tmp/ http://testdow ...

  7. 2.初始化spark

    参考:  RDD programming guide http://spark.apache.org/docs/latest/rdd-programming-guide.html  SQL progr ...

  8. [转]Hessian——轻量级远程调用方案

    Hessian是caucho公司开发的一种基于二进制RPC协议(Remote Procedure Call protocol)的轻量级远程调用框架.具有多种语言的实现,但用的最多的当然是Java实现 ...

  9. https搭建:ubuntu nginx配置 SSL证书

    HTTPS 是什么? 根据维基百科的解释: 超文本传输安全协议(缩写:HTTPS,英语:Hypertext Transfer Protocol Secure)是超文本传输协议和SSL/TLS的组合,用 ...

  10. OCCT 7.4.0 beta version is available

    OpenCASCADE 7.4.0测试版本发布 OCC在9月16号发布了opencascade740 beta测试版本,新版本里面做了如下一些重点修改如下: 造型算法部分主要对网格化算法BRepMes ...