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. TARS基金会:构建微服务开源生态

    导语 在20世纪60至70年代,软件开发人员通常在大型机和小型机上使用单体架构进行软件开发,没有一个应用程序能够满足大多数最终用户的需求.垂直行业使用的软件代码量更小,与其他应用程序的接口更简单,而可 ...

  2. Aircrack-ng无线审计工具破解无线密码

    Aircrack-ng工具 Aircrack-ng是一个与802.11标准的无线网络分析的安全软件,主要功能有网络探测.数据包嗅探捕获.WEP和WPA/WPA2-PSK破解.Aircrack可以工作在 ...

  3. python如何用format进行进制转换与如何删除进制前缀

    10进行十进制,十六进制,八进制,二进制的转换:(#:保留进制前缀)对于带着进制前缀的,如"0x"“0o”“0b”,可以直接在后面加上’x’‘o’'b’进行删除:其他的一些小技巧: ...

  4. javaScript 基础知识汇总 (十三)

    1.Class 在JavaScript中 calss即类是一种函数 基本语法 class Myclass{ constructor(){} method1(){} method2(){} method ...

  5. StormDRPC流程解读

    Storm 的编程模型是一个有向无环图,模型角度决定了 Storm 的 Spout 接收到外部系统的请求,将请求数据分发给下游的 bolt 进行处理后,spout 并不能得到 bolt 的处理结果并将 ...

  6. 使用numpy和PIL实现图像的手绘效果

    输入 输出 代码如下 图像的手绘效果的实现 from PIL import Image import numpy as np a = np.array(Image.open("index.j ...

  7. .net 4.0 以下HttpWebRequest Header 修改hosts方法

    .net 4.0 以下HttpWebRequest Header 修改hosts方法 特此记录 public class CusteredHeaderCollection : WebHeaderCol ...

  8. JSTL、请求转发和URL重定向

    JSTL 为什么要使用JSTL? 因为在JSP中写JAVA代码很麻烦,而JSTL可以简化在JSp中写JAva代码的流程 如何使用JSTL? 准备工作: ①将JSTL依赖的jar包导入工程的WEB-IN ...

  9. 大数据安装之Kafka(用于实时处理的消息队列)

    一.安装部署kafka 1.集群规划 hadoop102                                 hadoop103                          hado ...

  10. 解决tinyint映射成boolean/byte的问题

    前言 最近受疫情的影响,公司要做一个类似一码通的系统为客户服务.由我来进行表的设计.创建表之后需要逆向生成Java的entity.mapper.mapper.xml.由于我在数据库中定义了大量 tin ...