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 <string>
#include <cstring>
#include <algorithm>
using namespace std;
struct node
{
string name;
char sex;
string id;
int score;
}a[];
int main()
{
int n;
while(cin>>n){
int num_M=,num_F=;
int index_M=,index_F=;
int min_M=,max_F=;
for(int i=;i<n;i++){
cin>>a[i].name>>a[i].sex>>a[i].id>>a[i].score;
if(a[i].sex=='M'){
num_M++;
if(a[i].score<min_M){
index_M=i;
min_M=a[i].score;
}
}else if(a[i].sex=='F'){
num_F++;
if(a[i].score>max_F){
index_F=i;
max_F=a[i].score;
}
} }
if(num_F==){
cout<<"Absent"<<endl;
}else{
cout<<a[index_F].name<<" "<<a[index_F].id<<endl;
}
if(num_M==){
cout<<"Absent"<<endl;
}else{
cout<<a[index_M].name<<" "<<a[index_M].id<<endl;
}
if(num_M==||num_F==){
cout<<"NA"<<endl;
}else{
cout<<a[index_F].score-a[index_M].score<<endl;
}
}
return ;
}

PAT (Advanced Level) Practice 1036 Boys vs Girls (25 分)的更多相关文章

  1. PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...

  2. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...

  3. PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...

  4. PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...

  5. PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...

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

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

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

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

  8. PAT 1036 Boys vs Girls (25 分)

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

  9. 1036 Boys vs Girls (25分)(水)

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

随机推荐

  1. 一文带你了解 C# DLR 的世界

    一文带你了解 C# DLR 的世界 在很久之前,我写了一片文章dynamic结合匿名类型 匿名对象传参,里面我以为DLR内部是用反射实现的.因为那时候是心中想当然的认为只有反射能够在运行时解析对象的成 ...

  2. Charm Bracelet 一维01背包

    A - Charm Bracelet Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Su ...

  3. WinBox软路由的自定义IP设定

             软路由ros(MIKRTIK)安装简单步骤 由于本主也是刚刚接触软路由这个硬件方面的知识.所以也是略知皮毛而已,今天通过网上的学习,然后自己总结了一下怎么在软路由中设定一个自定义IP ...

  4. C++ 常用编程--Swap函数有几种写法?

    C++ 常用编程--Swap函数有几种写法? 在说C++模板的方法前,我们先想想C语言里面是怎么做交换的. 举个例子,要将两个int数值交换,是不是想到下面的代码: void swap(int& ...

  5. MySQL热机双备之双主同步复制配置

    此配置方案来源于csdn前辈博客,奈何找不到出处了,抱拳!!! 1.  MySQL同步机制概述 MySQL支持单向.异步复制,复制过程中一台服务器充当主服务器,一台或多台服务器充当从服务器,双主同步要 ...

  6. 【渗透实战】web渗透实战,手动拿学校站点 得到上万人的信息(漏洞已提交)

    ------------恢复内容开始------------ ’‘’版权tanee转发交流学校请备注漏洞已经提交学校管理员关键过程的截图和脚本代码已经略去.希望大家学习技术和思路就好,切勿进行违法犯罪 ...

  7. R语言入门:向量索引

    这节的内容是建立在之前我们对R语言最基本向量赋值的基础之上的,笔者本人学完R当中向量的索引感觉异常舒适,因为这个比Python的索引爽多了,是什么值开始索引就从哪里开始索引,到哪里结束就在哪里结束,而 ...

  8. SAP MM 采购订单与相关合同的价格差异问题分析

    SAP MM 采购订单与相关合同的价格差异问题分析 笔者所在的项目里,一般生产性物料PO的价格是来自于合同价格的,而合同的价格来自于采购信息记录的价格,业务部门不允许PO里随便改价格的. 但是业务部门 ...

  9. Android中调用另一个Activity并返回结果-以模拟选择头像功能为例

    场景 Android中点击按钮启动另一个Activity以及Activity之间传值: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/detail ...

  10. jq--实现自定义下拉框

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...