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. OpenXml Sdk 根据Word模板导出到word

    一:OpenXml Sdk 简介 Open XML标准的简单介绍:Ecma Office Open XML(“Open XML”)是针对字处理文档.演示文稿和电子表格的国际化开放标准,可免费供多个应用 ...

  2. XPath 实例

    在本节,让我们通过实例来学习一些基础的 XPath 语法. XML实例文档 我们将在下面的例子中使用这个 XML 文档: "books.xml" : <?xml versio ...

  3. Timusoj 1982. Electrification Plan

    http://acm.timus.ru/problem.aspx?space=1&num=1982 1982. Electrification Plan Time limit: 0.5 sec ...

  4. sublime text3 前端编译神器,浏览器实时显示

    前端编译器有很多,Dreamweaver,sublime text ,webstorm,但在使用之后感觉sublime text3就是前端的编译神器 首先sublime text3最好使用英文原版,虽 ...

  5. 夺命雷公狗-----React---22--小案例之react经典案例todos(完成数据的遍历)

    在很多前端框架中todos都是一个小的参考例子,在react中当然也是不例外的,先来看看最终的效果先... 这个就是官方的例子,我们先来分析下他是由那及格组建组合成的... 再来分析下他是的数据最终是 ...

  6. 【原创】如何用Android Studio断点安卓自带Service或Bind类型的Service

    很久以来,我一直想找一种方法来断点调试安卓系统自身的Service,或者bind类型的Service,比如我想看WifiManager里面的getWifiApConfiguration函数是如何实现的 ...

  7. OO Design

    什么是设计原则? 设计原则是基本的工具,应用这些规则可以使你的代码更加灵活.更容易维护.更容易扩展.基本原则:封装变化Encapsulate what varies.面向接口变成而不是实现 Code ...

  8. ubuntu16.04.1下的mysql修改默认编码

    在Ubuntu 下配置 Mysql 的字符编码.安装完 Mysql 后,系统默认的字符编码是 latin1 ,输入的是中文,可是输出却是一堆乱码.现在要做的就是把 Mysql的默认字符编码设置为支持中 ...

  9. Mysql中的少用函数

    1.查询时需要转换类型,大多发生在数字和字符串.时间和字符串之间 Mysql提供了两个个类型转换函数:CAST和CONVERT CAST() 和CONVERT() 函数可用来获取一个类型的值,并产生另 ...

  10. LINUX的磁盘管理du命令详解

    LINUX的磁盘管理du命令详解 du(disk usage)命令可以计算文件或目录所占的磁盘空间.没有指定任何选项时, 它会测量当前工作目录与其所有子目录,分别显示各个目录所占的快数,最后才显示工作 ...