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

题目分析:对数据进行处理就可 看了一下柳神的博客 更新相同排名不需要我这么麻烦
比如分数为 80 82 83 83 85
那么需要的排名应该为 1 2 3 3 5
经过处理得到未处理的排名为 1 2 3 4 5
if((*it).Score[i]==(*(it-1)).Score[i])
  (*it).Rank[i]=(*(it-1)).Rank[i];
这样可以了
 #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int flag = ;
char Project[] = { 'C','M','E','A' };
typedef struct Score
{
int Student_Id;
int score[];
int Rank[];
int High;
int Pro;
}Scores;
bool compare(const Scores& a, const Scores& b)
{
return a.score[flag] > b.score[flag];
}
int main()
{
vector<Scores> S;
int N, M;
cin >> N >> M;
Scores t;
for (int i = ; i < N; i++)
{
cin >> t.Student_Id >> t.score[] >> t.score[] >> t.score[];
t.score[] = (t.score[] + t.score[] + t.score[]) / ;
S.push_back(t);
}
for (int i = ; i < ; i++)
{
sort(S.begin(), S.end(), compare);
(*S.begin()).Rank[flag] = ;
int j = ;
int truej = ;
for (vector<Scores>::iterator it = S.begin()+; it != S.end(); it++)
{
if ((*(it - )).score[flag] == (*it).score[flag])
{
(*it).Rank[flag] = j;
truej++;
}
else
{
(*it).Rank[flag] = truej;
j = truej++;
}
}
flag++;
}
for (vector<Scores>::iterator it = S.begin(); it != S.end(); it++)
{
int min = ;
int minp = ;
for (int i = ; i < ; i++)
{
if (min > (*it).Rank[i])
{
min = (*it).Rank[i];
minp = i;
}
}
if ((*it).Rank[] <=min)
{
min = (*it).Rank[];
minp = ;
}
(*it).High = min+;
(*it).Pro = minp;
}
for (int i = ; i < M; i++)
{
cin >> t.Student_Id;
int flag =;
for (vector<Scores>::iterator it = S.begin(); it != S.end(); it++)
if ((*it).Student_Id == t.Student_Id)
{
cout << (*it).High << " " << Project[(*it).Pro] << endl;
flag = ;
break;
}
if (!flag)
cout << "N/A"<<endl;
}
return ;
}

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

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

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

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

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

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

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

  4. 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 ...

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

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

  6. 1012. The Best Rank (25)

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

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

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

  8. PAT-1012 The Best Rank (25 分) 查询分数对应排名(包括并列)

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

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

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

随机推荐

  1. python学习列表(Lists).基础二

    列表(Lists) 序列是Python中最基本的数据结构,序列中的每个元素都分配一个数字,它的第一个索引是0第二个索引是1,依次类推. 列表是最常用的Python数据类型,它可以作为一个方括号内的逗号 ...

  2. web实验二 ---通过jQuery实现用户注册身份验证

    通过jQuery实现用户注册身份验证,当每个文本框失去焦点时进行该文本框内容校验,并将校验信息在文本框右侧显示出结果. 具体校验要求: 1.用户名由6-18位字符组成 2.密码由6-18位字符组成,且 ...

  3. 网络|N1盒子做旁路由刷OpenWRT系统(小白专用)

    N1盒子做旁路由刷OpenWRT系统(小白专用) 为什么要用N1盒子 现如今新上市的路由器,市面上能买到的300元以内的路由器大多数都是双频(5G Hz和2.4G Hz)和几年前相比无论是速度还是性能 ...

  4. win10 安装虚拟机提示 主IP地址显示网络信息不可用

    问题:在虚拟机详情下面显示 主ip地址:网络信息不可用 解决办法: 先root用户[root@dfhf~]#cd ..[root@dfhf/]#cd /etc/sysconfig/network-sc ...

  5. C++ 继承函数

    #include <iostream> using namespace std; class passport { public: passport() //默认构造 { } passpo ...

  6. Spark入门(四)--Spark的map、flatMap、mapToPair

    spark的RDD操作 在上一节Spark经典的单词统计中,了解了几个RDD操作,包括flatMap,map,reduceByKey,以及后面简化的方案,countByValue.那么这一节将介绍更多 ...

  7. 如何使用Logstash

    目录 一.什么是Logstash 二.如何安装 三.快速使用 四.Input输入插件 五.codec编码插件 六.filter过滤器插件 七.output输出插件 八.总结 一.什么是Logstash ...

  8. kb4019990 补丁导致wpf无法启动异常

     问题补丁:[Microsoft Update Catalog](https://www.catalog.update.microsoft.com/Search.aspx?q=kb4019990 )  ...

  9. Java 14 发布了,再也不怕 NullPointerException 了!

    2020年3月17日发布,Java正式发布了JDK 14 ,目前已经可以开放下载.在JDK 14中,共有16个新特性,本文主要来介绍其中的一个特性:JEP 358: Helpful NullPoint ...

  10. 题解 P4325 【[COCI2006-2007#1] Modulo】

    第\(1\)种方法 也是最暴力的一种 我们熟知,\(c++\)中的\(set\)可以既去重,有排序,这题,我们可以用set来搞,虽然我们不需要排序的功能,但毕竟方便,一共是\(10\)个数,所以暴力一 ...