1012 The Best Rank (25分)
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 C, M, E 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 (≤2000), 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 C, M 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
这题是PAT甲级的1012题,题目描述为英文,题目的意思为:
1012的最好排名(25分)
为了评估我们第一年CS专业学生的表现,我们只考虑他们三门课程的成绩:C - C编程语言,M -数学(微积分或线性代数),和E -英语。同时,我们通过强调学生的最好等级来鼓励他们——也就是说,在三门课程和平均成绩的四个等级中,我们为每个学生打印出最好的等级。
例如,4名学生的C、M、E、A -的平均成绩如下:
学生ID C M E A
310101 98 85 88 90
310102 70 95 88 84
310103 82 87 94 88
310104 91 91 91 91
所有学生的最好成绩排名第一,因为第一名的C语言成绩最好,第二名的数学成绩最好,第三名的英语成绩最好,最后一名的平均成绩最好。
输入规格:
每个输入文件包含一个测试用例。每个案例都以一行开始,其中包含两个数字N和M(≤2000),这两个数字分别是学生总数和检查其排名的学生人数。然后是N行,每一行包含一个学生ID,它是一个6位数的字符串,后面是该学生的三个整数等级(范围为[0,100]),顺序为C、M和e。然后是M行,每一行包含一个学生ID。
输出规范:
对于每一位M名学生,打印出他/她的最佳排名,以及相应排名的符号,用空格隔开。
排序方法的优先级按 A>C>M>E排序。因此,如果一个学生有两种或两种以上的方法来获得相同的最佳排名,则输出优先级最高的方法。
如果一个学生不在评分名单上,简单地输出N/A。
示例输入:
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
输出示例:
1 C
1 M
1 E
1
3
N/A