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 (≤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 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
分析:sort排序题,由于要记录每科成绩的排名,可以用Rank[id][now]来记录学科排名,如果直接记录在结构体里面会超时,因为每次查询时需要遍历一遍,查询数量足够大的时候会超时。
/**
* Copyright(c)
* All rights reserved.
* Author : Mered1th
* Date : 2019-02-25-15.41.18
* Description : A1012
*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<map>
#include<vector>
#include<set>
using namespace std;
struct Student{
int id;
];//4门成绩
}stu[];
]={'A','C','M','E'};
int now;
bool cmp(Student a,Student b){
return a.grade[now]>b.grade[now];
}
][]={};
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
int n,m;
scanf("%d%d",&n,&m);
;i<n;i++){
scanf(],&stu[i].grade[],&stu[i].grade[]);
stu[i].grade[]=(stu[i].grade[]+stu[i].grade[]+stu[i].grade[])/3.0;
}
;now<;now++){
sort(stu,stu+n,cmp);
Rank[stu[].id][now]=;
;i<n;i++){
].grade[now]){
Rank[stu[i].id][now]=Rank[stu[i-].id][now];
}
else{
Rank[stu[i].id][now]=i+;
}
}
}
int queryid;
;i<m;i++){
scanf("%d",&queryid);
]==){
printf("N/A\n");
}
else{
;
;j<;j++){
if(Rank[queryid][j]<Rank[queryid][best]){
best=j;
}
}
printf("%d %c\n",Rank[queryid][best],course[best]);
}
}
;
}
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 - 英语.同时,我们鼓励学生强调自己的最优秀队伍 - 也就是说 ...
- 1012 The Best Rank (25 分)
To evaluate the performance of our first year CS majored students, we consider their grades of three ...
- 【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 ...
随机推荐
- ASP.NET下跨应用共享Session和使用Redis进行Session托管
在之前的博客中,我说到了Session的共享问题,其中说到了Web Farm和Web Garden两种情况下Session的处理.在ASP.NET提供的Session处理方法中,有以下四种模式: 1. ...
- 2019.1.22 zigbee test
1传输测试 频谱仪设置: sigfox 模块串口设置: 自动选择对应型号 Test step: PS:发送TX指令 AT$cw=波特率,通道,uint 这里有个问题--不应该只发送一次 ------- ...
- path--diff
vdom--patch(一)我们讲了,整个Vue对象初始化并渲染到页面中的过程. 本篇文章我们主要来谈谈当页面绑定的数据修改后,是如何更新dom结构的, 即vdom的diff算法,网上讲解这部分内容的 ...
- 利用nexus5伪造一张门禁卡
0×00 前言 我租住的杭州一个老小区一年前出现了所谓的“出租房杀人事件”,事件过后民警叔叔们给小区的每个单元都装上了门禁,所有住户都需要在物业处登记,物业的工作人员会让你提供身份证或者公交卡用来注册 ...
- SSH 获取GET/POST参数
在做项目的API通知接口的时候,发现在SSH框架中无法获取到对方服务器发来的异步通知信息.最后排查到的原因可能是struts2对HttpServletRequest进行了二次处理,那么该如何拿到pos ...
- Linux环境下 多线程下载 (Python 实现版)
本文是多年前学习编程时参照一个网友程序的基础之上改写的, 采用Python语音编写, 多线程下载功能, 可以有效提高Linux下原有下载工具中的一些不足,以下给出具体代码. #!/usr/bin/py ...
- Web Components 是什么
/********************************************************************************* * Web Components ...
- U-Boot_bmp_logo_hacking
/*********************************************************************** * U-Boot_bmp_logo_hacking * ...
- shell 脚本实战笔记(3)--集群机器的时间同步设置
背景: 有些分布式服务(比如HBase服务), 依赖于系统时间戳, 如果集群各个节点, 系统时间不一致, 导致服务出现诡异的情况. 解决方案: 那如何同步集群各个节点之间的时间? 采用NTP(Netw ...
- [LeetCode&Python] Problem 876. Middle of the Linked List
Given a non-empty, singly linked list with head node head, return a middle node of linked list. If t ...