This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.

Input Specification:

Each input file contains one test case. Each case contains a positive integer N, followed by N lines of student information. Each line contains a student's namegenderID and grade, separated by a space, where name and ID are strings of no more than 10 characters with no space, gender is either F (female) or M (male), and grade is an integer between 0 and 100. It is guaranteed that all the grades are distinct.

Output Specification:

For each test case, output in 3 lines. The first line gives the name and ID of the female student with the highest grade, and the second line gives that of the male student with the lowest grade. The third line gives the difference grade​F​​−grade​M​​. If one such kind of student is missing, output Absent in the corresponding line, and output NA in the third line instead.

Sample Input 1:

3
Joe M Math990112 89
Mike M CS991301 100
Mary F EE990830 95

Sample Output 1:

Mary EE990830
Joe Math990112
6

Sample Input 2:

1
Jean M AA980920 60

Sample Output 2:

Absent
Jean AA980920
NA
 #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int N;
struct Node
{
string name, gender, ID;
int grade;
}node;
int main()
{
cin >> N;
vector<Node>male, female; //此代码是将数据保存下来排序,还可以直接在输入时就得到最高分和最低分,这样就大大节省了空间和时间
for (int i = ; i < N; ++i)
{
cin >> node.name >> node.gender >> node.ID >> node.grade;
if (node.gender == "M")
male.push_back(node);
else
female.push_back(node);
}
sort(male.begin(), male.end(), [](Node a, Node b) {return a.grade < b.grade; });
sort(female.begin(), female.end(), [](Node a, Node b) {return a.grade > b.grade; });
if (female.size() == )
cout << "Absent" << endl;
else
cout << female[].name << " " << female[].ID << endl;
if (male.size() == )
cout << "Absent" << endl;
else
cout << male[].name << " " << male[].ID << endl;
if (female.size() == || male.size() == )
cout << "NA" << endl;
else
cout << female[].grade - male[].grade << endl;
return ;
}

PAT甲级——A1036 Boys vs Girls的更多相关文章

  1. PAT 甲级 1036 Boys vs Girls (25 分)(简单题)

    1036 Boys vs Girls (25 分)   This time you are asked to tell the difference between the lowest grade ...

  2. PAT甲级——1036 Boys vs Girls

    1036 Boys vs Girls This time you are asked to tell the difference between the lowest grade of all th ...

  3. PAT 甲级 1036 Boys vs Girls(20)

    https://pintia.cn/problem-sets/994805342720868352/problems/994805453203030016 This time you are aske ...

  4. PAT A1036 Boys vs Girls(25)

    AC代码 #include <cstdio> #include <algorithm> using namespace std; const int max_n = 11000 ...

  5. A1036. Boys vs Girls

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  6. PAT Advanced 1036 Boys vs Girls (25 分)

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  7. PAT甲级:1036 Boys vs Girls (25分)

    PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...

  8. PAT 1036 Boys vs Girls[简单]

    1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...

  9. PAT 1036 Boys vs Girls (25 分)

    1036 Boys vs Girls (25 分)   This time you are asked to tell the difference between the lowest grade ...

随机推荐

  1. 2015年MBA备考心得

    2015年12月份山大MBA备考心得 我在去年的12月26日参加了山大的MBA招生考试,在今年3月底参加了山大的复试,并被山大录取.初试英语70分,综合部分151,总分在今年的山大考生中是第16名:复 ...

  2. error C2712: Cannot use __try in functions that require object unwinding

    转自VC错误:http://www.vcerror.com/?p=52 问题描述: error C2712: Cannot use __try in functions that require ob ...

  3. 基于Java Properties类设置本地配置文件

    一.Java Properties类介绍 Java中有个比较重要的类Properties(Java.util.Properties),主要用于读取Java的配置文件,各种语言都有自己所支持的配置文件, ...

  4. Markdown语法--整理

    Markdown基本语法 [TOC] 优点: 1.因为是纯文本,所以只要支持Markdown的地方都能获得一样的编辑效果,可以让作者摆脱排版的困扰,专心写作. 2.操作简单.比如:word编辑时标记个 ...

  5. thinkone无法重新创建数据库的问题 newsy

    错误描述: 无法加载数据库驱动: Think\Db\Driver\    前后装了OneThink1.0和OneThink1.1都没成功,都是卡在了安装页面的三个step,读者们你们也遇到一样的情况吗 ...

  6. JS数组 呼叫团里成员(使用数组元素) myarray[0]

    呼叫团里成员(使用数组元素) 我们知道数组中的每个值有一个索引号,从0开始,如下图, myarray变量存储6个人的成绩:   要得到一个数组元素的值,只需引用数组变量并提供一个索引,如: 第一个人的 ...

  7. 转载别人的ftp,觉得目录结构不错,学习

    开发简单的FTP:1. 用户登陆2. 上传/下载文件3. 不同用户家目录不同4. 查看当前目录下文件5. 充分使用面向对象知识 REDMAE 1 用户登陆 2 3 1.查看用户目录文件 4 2.上传文 ...

  8. CF596D Wilbur and Trees

    题意:有一些高度为h的树在数轴上.每次选择剩下的树中最左边或是最右边的树推倒(各50%概率),往左倒有p的概率,往右倒1-p. 一棵树倒了,如果挨到的另一棵树与该数的距离严格小于h,那么它也会往同方向 ...

  9. WPF 多语言

    1.http://www.cnblogs.com/bear831204/archive/2009/03/17/1414026.html 2.http://www.cnblogs.com/horan/a ...

  10. Nginx的安装--------tar包安装

    Nginx的安装,在网上搜索是很多的结果,但是 真的安装起来却花费了不少 心思,总结起来就是依赖包安装了,但是没有指定对的路径,在安装的过程中遇到过两个问题: ①make[1]: *** [/usr/ ...