1012 The Best Rank (25 分)
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 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 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 C
, M
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 分)的更多相关文章
- 1012 The Best Rank (25分) vector与结构体排序
1012 The Best Rank (25分) To evaluate the performance of our first year CS majored students, we con ...
- PAT 甲级 1012 The Best Rank (25 分)(结构体排序)
题意: 为了评估我们第一年的CS专业学生的表现,我们只考虑他们的三个课程的成绩:C - C编程语言,M - 数学(微积分或线性代数)和E - 英语.同时,我们鼓励学生强调自己的最优秀队伍 - 也就是说 ...
- 【PAT甲级】1012 The Best Rank (25 分)
题意: 输入两个整数N,M(<=2000),接着分别输入N个学生的ID,C语言成绩,数学成绩和英语成绩. M次询问,每次输入学生ID,如果该ID不存在则输出N/A,存在则输出该学生排名最考前的一 ...
- 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 ...
- 【PAT】1012. The Best Rank (25)
题目链接: http://pat.zju.edu.cn/contests/pat-a-practise/1012 题目描述: To evaluate the performance of our fi ...
- 1012. The Best Rank (25)
To evaluate the performance of our first year CS majored students, we consider their grades of three ...
- 1012 The Best Rank (25)(25 point(s))
problem To evaluate the performance of our first year CS majored students, we consider their grades ...
- PAT-1012 The Best Rank (25 分) 查询分数对应排名(包括并列)
To evaluate the performance of our first year CS majored students, we consider their grades of three ...
- PAT (Advanced Level) 1012. The Best Rank (25)
简单排序题. 注意:分数相同的人排名相同. #include<iostream> #include<cstring> #include<cmath> #includ ...
随机推荐
- 通过mockjs来制作假数据
需用用到的模块为express和mockjs //导入模块开启服务器模块 const express=require('express') //导入假数据模块 const mockjs=require ...
- HashMap 速描
HashMap 速描 之前简单的整理了Java集合的相关知识,发现HashMap并不是三言两语能够讲明白的,所以专门整理一下HashMap的相关知识. HashMap 存储结构 HashMap是一个哈 ...
- 【S2-053】Struts2远程命令执行漏洞(CVE-2017-12611)
继S2-052之后,Apache Struts 2再次被曝存在远程代码执行漏洞,漏洞编号S2-053,CVE编号CVE-2017-1000112. 当开发人员在Freemarker标签中使用错误的构造 ...
- chrome 和 chromeDriver
在写selenium的时候,发现很简单的case也报错 package com.lv.test; import org.junit.Test; import org.openqa.selenium.W ...
- Redis07——Redis到底能用在什么地方(下)
在前一篇文章中,我们已经介绍过Redis的一些实际应用.如KV缓存.分布式锁.消息队列,由于篇幅原因,并未介绍完全.接下来将继续为各位带来Redis的更多应用. bitmat(位图) 实现 位图的基本 ...
- xpath提取标签和内容
转:https://segmentfault.com/q/1010000012110138/a-1020000012113020 <div> <table> <tr> ...
- java-随机点名器(新手)
//创建的一个包名. package qige; //导入一个包.import java.util.Random; //定义一个类.public class Zy1 { //公共静态的主方法. pub ...
- Natas0 Writeup(前端源码、敏感信息)
Natas0: 提示密码就在本页,右键查看源码,注释中发现flag. flag:gtVrDuiDfck831PqWsLEZy5gyDz1clto 总结:客户端代码注释中切勿保存敏感信息.
- Deep Protein Methylation Profiling by Combined Chemical and Immunoaffinity Approaches Reveals Novel PRMT1 Targets (结合层析法和免疫沉淀法的蛋白甲基化的深度检测技术发现了PRMT1新的靶标蛋白)
题目:Deep Protein Methylation Profiling by Combined Chemical and Immunoaffinity Approaches Reveals Nov ...
- Centos 非root用户安装rabbitmq
RabbitMQ是一个开源消息队列服务器,您可以使用它来构建您的消息传递应用程序.简单地说,您可以将来自一个应用程序的消息放入队列,并从来自相同应用程序或不同应用程序的队列中检索消息.您可以使用多种编 ...