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 Algebra), 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

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

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 题目不难,就是自己代码写的好渣..
就有一个情况第一次没考虑到,就是出现相同排名的时候,修改后就过了
#include <iostream>
#include <map>
#include <cstdio> using namespace std; typedef struct Student{
string ID;
int c;
int m;
int e;
int a;
}Student; Student s[];
string CID[];
map<string,int> a;
map<string,int> c;
map<string,int> m;
map<string,int> e; int main()
{
int n,k;
char t;
cin>>n>>k;
for(int i=;i<n;i++){
cin>>s[i].ID>>s[i].c>>s[i].m>>s[i].e;
s[i].a=(s[i].c+s[i].m+s[i].e)/;
}
Student temp;
for(int i=;i<n;i++){
for(int j=i;j<n;j++){
if(s[i].a<s[j].a){
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
}
}
a[s[].ID]=;
for(int i=;i<n;i++){
if(s[i].a==s[i-].a) a[s[i].ID]=a[s[i-].ID];
else a[s[i].ID]=i+;
} for(int i=;i<n;i++){
for(int j=i;j<n;j++){
if(s[i].c<s[j].c){
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
}
}
c[s[].ID]=;
for(int i=;i<n;i++){
if(s[i].c==s[i-].c) c[s[i].ID]=c[s[i-].ID];
else c[s[i].ID]=i+;
} for(int i=;i<n;i++){
for(int j=i;j<n;j++){
if(s[i].m<s[j].m){
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
}
}
m[s[].ID]=;
for(int i=;i<n;i++){
if(s[i].m==s[i-].m) m[s[i].ID]=m[s[i-].ID];
else m[s[i].ID]=i+;
} for(int i=;i<n;i++){
for(int j=i;j<n;j++){
if(s[i].e<s[j].e){
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
}
}
e[s[].ID]=;
for(int i=;i<n;i++){
if(s[i].e==s[i-].e) e[s[i].ID]=e[s[i-].ID];
else e[s[i].ID]=i+;
} for(int i=;i<k;i++){
cin>>CID[i];
} for(int i=;i<k;i++){
int min=;
if (a.count(CID[i])==) {cout<<"N/A"<<endl;}
else{
if(a[CID[i]]<min) {min=a[CID[i]];t='A';}
if(c[CID[i]]<min) {min=c[CID[i]];t='C';}
if(m[CID[i]]<min) {min=m[CID[i]];t='M';}
if(e[CID[i]]<min) {min=e[CID[i]];t='E';}
cout<<min<<" "<<t<<endl;
}
} return ;
}

1012. The Best Rank (25)的更多相关文章

  1. PAT甲 1012. The Best Rank (25) 2016-09-09 23:09 28人阅读 评论(0) 收藏

    1012. The Best Rank (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...

  2. 1012 The Best Rank (25分) vector与结构体排序

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

  3. 【PAT】1012. The Best Rank (25)

    题目链接: http://pat.zju.edu.cn/contests/pat-a-practise/1012 题目描述: To evaluate the performance of our fi ...

  4. 1012 The Best Rank (25)(25 point(s))

    problem To evaluate the performance of our first year CS majored students, we consider their grades ...

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

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

  6. 1012 The Best Rank (25 分)

    To evaluate the performance of our first year CS majored students, we consider their grades of three ...

  7. PAT (Advanced Level) 1012. The Best Rank (25)

    简单排序题. 注意:分数相同的人排名相同. #include<iostream> #include<cstring> #include<cmath> #includ ...

  8. PAT甲题题解-1012. The Best Rank (25)-排序水题

    排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询 ...

  9. 【PAT甲级】1012 The Best Rank (25 分)

    题意: 输入两个整数N,M(<=2000),接着分别输入N个学生的ID,C语言成绩,数学成绩和英语成绩. M次询问,每次输入学生ID,如果该ID不存在则输出N/A,存在则输出该学生排名最考前的一 ...

随机推荐

  1. JavaSE基础第一篇

      1.JDK的安装: 包括JRE 和JVM   下载地址: www.oracle.com/www.sun.com 2.环境变量 set path = "bin所在路径" 设置pa ...

  2. android sdk manager国内无法更新的解决办法

  3. Hdu 1214 圆桌会议

    圆桌会议 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  4. java String 详解

    1.java语言的字符串序列是通过字符串类实现的.java提供了3个字符串类:String类.StringBuilder类和StringBuffer类.String类是不变字符串,StringBuff ...

  5. linux shell脚本使用结构化命令(2)

    一.for命令 二.while命令 三.until命令 1.for命令基本格式 for var in list do commands done oracle@suse:~/testshell> ...

  6. XAF 如何将数据库中Byte array图片显示出来

    问题比较简单,直接上代码. private Image _Cover; [Size(SizeAttribute.Unlimited), ValueConverter(typeof(ImageValue ...

  7. Swift_UI_UILabel

    Swift_UI_UILabel import UIKit class ViewController: UIViewController { override func viewDidLoad() { ...

  8. [转]Android SDK更新 Connection to http://dl-ssl.google.com refused 解决方法

    问题描述 使用SDK Manager更新时出现问题Failed to fetch URL https://dl-ssl.google.com/android/repository/repository ...

  9. Linux驱动程序学习【转】

    本文转载自: 一直在学习驱动,对于下面这篇文章,本人觉得简洁明了,基本符合我们学习驱动的进度与过程,现转发到自己的博客,希望能与更多的朋友分享. 了解Linux驱动程序技巧学习的方法很重要,学习lin ...

  10. 07-阻塞赋值与非阻塞赋值原理分析——小梅哥FPGA设计思想与验证方法视频教程配套文档

    芯航线--普利斯队长精心奉献   实验目的:掌握阻塞赋值与非阻塞赋值的区别 实验平台:无 实验原理:     阻塞赋值,操作符为"=","阻塞"是指在进程语句( ...