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 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 (≤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 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

分析: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 分)的更多相关文章

  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. 1012 The Best Rank (25 分)

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

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

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

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

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

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

  7. 1012. The Best Rank (25)

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

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

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

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

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

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

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

随机推荐

  1. 关于学习JAVA程序设计语言的回顾与展望

    回顾篇 时光荏苒,大学生活已然过半.看了老师分享的几篇博文,我的内心是震憾并且惭愧的.相比别人,自己做的实在是不够多,不够好.在刚刚结束的大二上半学期,我学习了JAVA初级程序设计,虽然每节课都认真听 ...

  2. CMMI的5个级别

    为了帮助软件企业对软件工程过程进行管理和改进,增强开发与改进能力,从而能按时地.不超预算地开发出高质量的软件,美国国防部与卡内基-梅隆大学和美国国防工业协会共同开发和研制了CMMI(软件能力成熟度模型 ...

  3. Linux C 文件操作函数(~上善止水~)

    翻翻笔记,整理一下 C 语言中的文件操作函数 ~~~~~~,多注意细节,maybe 细节决定成败~ 1. fopen /* fopen(打开文件) * * 相关函数 open,fclose * * 表 ...

  4. opencv2.4.10与VS2013的环境配置

    前言 项目几乎都是图像相关的,一般都会用到opencv开源库,就涉及到windows下opencv的环境配置问题,本文对此进行介绍. 环境 系统环境:win10_x64(其他windows系统类似); ...

  5. Docker私有镜像仓库

    使用阿里云加速: tee /etc/docker/daemon.json << 'EOF' { "registry-mirrors": [ "https:// ...

  6. ElasticSearch(五):简单的ElasticSearch搜索功能

    这里主要是一些简单的ElasticSearch的搜索功能,复杂的搜索,比如过滤,聚合等以后单独在写 1. 搜索全部 GET book/_search 直接搜索全部,下面是对搜索结果的详细介绍:默认情况 ...

  7. hdu 5311(暴力)

    题意:要求在一个字符串中找出三段,然后能拼成一个固定的单词,问是否可行 BC周年庆第二题,我枚举了那个单词的切断位置,然后到给的字符串里分别找,然后就没有然后了``` #include<stdi ...

  8. WPF 带CheckBox、图标的TreeView(转)

    在WPF实际项目开发的时候,经常会用到带CheckBox的TreeView,虽然微软在WPF的TreeView中没有提供该功能,但是微软在WPF中提供强大的ItemTemplate模板功能和自定义样式 ...

  9. 剑指offer-顺时针打印矩阵-二维数组

    输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1     2  3    4 5     6  7    8 9   10 11 12 13 14 15 16 ...

  10. 两个有用Oracle运算:intersect和minus运算

    intersect运算 返回查询结果中相同的部分 exp:各个部门中有哪些相同的工种 select job from account intersect select job from researc ...