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. Oracle学习笔记--Oracle启动过程归纳整理

    Oracle 启动过程分为nomount状态mount状态open状态 每个状态下Oracle都会进行不同的操作:1.nomount状态 在$ORACLE_HOME/dbs目录下寻找参数文件 参数文件 ...

  2. 单元测试 - Tests和UITests (一) 业务测试

    单元测试 假如我们今天去面试了,面试官问了一句“什么是单元测试?有没有使用?大概是针对那些情况进行单测的?单测意义从你实际使用中总结一下.” 这要在我没进行现在的单测之前这个问题我回答的可能就是“不好 ...

  3. (转)解决windows live writer的段首缩进问题

    原文地址:http://blog.csdn.net/xiao_wanpeng/article/details/6381799 Windows live writer 默认是没有段首缩进的,并且不能修改 ...

  4. vscode在执行 npm任务的时候,会先执行package的name@version 然后命令名 加 当前路径,问题是我的引入路径e是小写的,会导致调试错误,解决方案:没找到,先手书吧

    vscode在执行 npm任务的时候,会先执行package的name@version 然后命令名 加 当前路径,问题是我的引入路径e是小写的,会导致调试错误,解决方案:没找到 Executing t ...

  5. 三、create-react-app新旧版中使用less和antd并修改主题颜色

    引入less 如果项目根目录中没有config文件夹,首先暴露出项目配置文件,项目下执行: npm run eject 如果项目是从git仓库中pull下来的的话,必须确保本地项目与仓库中没有冲突,才 ...

  6. 阅读GitHub源码的正确打开方式

    前言 近来发现阅读开源项目上手就整最新的代码不合适,缺少项目迭代的具体实现过程,想着若是可以看到针对问题的提交代码就好了,所以就有了本篇博客. 以文主要涉及:如何fork开源项目,如何保证本地仓库代码 ...

  7. C++ 人脸识别系统的浅理解

    机器学习 机器学习的目的是把数据转换成信息. 机器学习通过从数据里提取规则或模式来把数据转成信息. 人脸识别 人脸识别通过级联分类器对特征的分级筛选来确定是否是人脸. 每个节点的正确识别率很高,但正确 ...

  8. Natas2 Writeup(水平越权)

    Natas2: 查看源码,发现页面隐藏了一个图片的连接,分析图片,无隐写内容,联想到目录权限问题,访问同级目录http://natas2.natas.labs.overthewire.org/file ...

  9. Effective Python读书笔记

    有些位置可能翻译理解的不到位,各位看官如有疑问,欢迎留言赐教. Pythonic Thinking 大家经常用Pythonic来形容python语法风格的编程方式:简单优美,没有之一:通过import ...

  10. ASP.NET Core应用的7种依赖注入方式

    ASP.NET Core框架中的很多核心对象都是通过依赖注入方式提供的,如用来对应用进行初始化的Startup对象.中间件对象,以及ASP.NET Core MVC应用中的Controller对象和V ...