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:

  1. StudentID C M E A
  2. 310101 98 85 88 90
  3. 310102 70 95 88 84
  4. 310103 82 87 94 88
  5. 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:

  1. 5 6
  2. 310101 98 85 88
  3. 310102 70 95 88
  4. 310103 82 87 94
  5. 310104 91 91 91
  6. 310105 85 90 90
  7. 310101
  8. 310102
  9. 310103
  10. 310104
  11. 310105
  12. 999999

Sample Output:

  1. 1 C
  2. 1 M
  3. 1 E
  4. 1 A
  5. 3 A
  6. 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];
    这样可以了
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4. using namespace std;
  5. int flag = ;
  6. char Project[] = { 'C','M','E','A' };
  7. typedef struct Score
  8. {
  9. int Student_Id;
  10. int score[];
  11. int Rank[];
  12. int High;
  13. int Pro;
  14. }Scores;
  15. bool compare(const Scores& a, const Scores& b)
  16. {
  17. return a.score[flag] > b.score[flag];
  18. }
  19. int main()
  20. {
  21. vector<Scores> S;
  22. int N, M;
  23. cin >> N >> M;
  24. Scores t;
  25. for (int i = ; i < N; i++)
  26. {
  27. cin >> t.Student_Id >> t.score[] >> t.score[] >> t.score[];
  28. t.score[] = (t.score[] + t.score[] + t.score[]) / ;
  29. S.push_back(t);
  30. }
  31. for (int i = ; i < ; i++)
  32. {
  33. sort(S.begin(), S.end(), compare);
  34. (*S.begin()).Rank[flag] = ;
  35. int j = ;
  36. int truej = ;
  37. for (vector<Scores>::iterator it = S.begin()+; it != S.end(); it++)
  38. {
  39. if ((*(it - )).score[flag] == (*it).score[flag])
  40. {
  41. (*it).Rank[flag] = j;
  42. truej++;
  43. }
  44. else
  45. {
  46. (*it).Rank[flag] = truej;
  47. j = truej++;
  48. }
  49. }
  50. flag++;
  51. }
  52. for (vector<Scores>::iterator it = S.begin(); it != S.end(); it++)
  53. {
  54. int min = ;
  55. int minp = ;
  56. for (int i = ; i < ; i++)
  57. {
  58. if (min > (*it).Rank[i])
  59. {
  60. min = (*it).Rank[i];
  61. minp = i;
  62. }
  63. }
  64. if ((*it).Rank[] <=min)
  65. {
  66. min = (*it).Rank[];
  67. minp = ;
  68. }
  69. (*it).High = min+;
  70. (*it).Pro = minp;
  71. }
  72. for (int i = ; i < M; i++)
  73. {
  74. cin >> t.Student_Id;
  75. int flag =;
  76. for (vector<Scores>::iterator it = S.begin(); it != S.end(); it++)
  77. if ((*it).Student_Id == t.Student_Id)
  78. {
  79. cout << (*it).High << " " << Project[(*it).Pro] << endl;
  80. flag = ;
  81. break;
  82. }
  83. if (!flag)
  84. cout << "N/A"<<endl;
  85. }
  86. return ;
  87. }

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. Java easyui 下拉框默认选中第一个

    html代码: <tr> <td> <div style="margin-bottom:5px">计价方式:   <%--下拉框默认选中第 ...

  2. 关于.NET中的控制反转及AutoFac的简单说明

    目录 1.控制反转 1.1 什么是依赖? 1.2 什么是控制反转? 1.3 什么是依赖注入? 1.4 简单总结 2.控制反转容器 2.1 IOC容器说明 2.2 使用AutoFac的简介示例 3 使用 ...

  3. search(1)- elasticsearch结构概念

    上篇提到选择了elasticsearch ES作为专业化搜索引擎的核心,这篇讨论一下ES的基本结构和应用概念.首先,从硬结构方面来讲:ES是在一个集群(cluster)环境里运行的,所以ES应该具备高 ...

  4. python基础学习day03

    基础数据类型总览 why:机器无法像人一样分编各种类型 int(数字) str(字符串)作用:存储少量信息. '12','我和你','qw' bool值 作用:判断真假 True False list ...

  5. 2019计蒜客信息学提高组赛前膜你赛 #2(TooYoung,TooSimple,Sometimes Naive

    计蒜客\(2019CSP\)比赛第二场 巧妙爆零这场比赛(我连背包都不会了\(QWQ\) \(T1\) \(Too\) \(Young\) 大学选课真的是一件很苦恼的事呢! \(Marco\):&qu ...

  6. 《ASP.NET Core 3框架揭秘》5折预售暨样章发布

    <ASP.NET Core 3框架揭秘>于昨天在下午京东正式开始预售,并在半天之内销售近一千套.为了回馈读者,出版社与京东谈了一个5折的价格.与此同时,我将本书最核心的内容作为样章(3章) ...

  7. VS2019 C++动态链接库的创建使用(2) - 客户调用接口

    因为动态链接库里的内容是自己定义的,所以在外部程序调用时我们自己知道库里包含哪些变量和函数,如果我们提供库给其他人使用,则最好增加一个头文件,告知库里包含的函数: ①将动态链接库源文件内容增加红色框内 ...

  8. Spring Data JPA 自定义对象接收查询结果集

    Spring Data JPA 简介 Spring Data JPA 是 Spring 基于 ORM 框架.JPA 规范的基础上封装的一套JPA应用框架,可使开发者用极简的代码即可实现对数据库的访问和 ...

  9. 201771010103 陈亚茹 《面向对象程序设计(java)》第一周学习总结

    本人学号<面向对象程序设计(java)>第一周学习总结 第一部分:课程准备部分 填写课程学习 平台注册账号, 平台名称 注册账号 博客园:www.cnblogs.com https://w ...

  10. 计算几何-Minimum Area Rectangle II

    2020-02-10 21:02:13 问题描述: 问题求解: 本题由于可以暴力求解,所以不是特别难,主要是用来熟悉计算几何的一些知识点的. public double minAreaFreeRect ...