#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct Student{
string name;
string gender;
string id;
int grade;
int idd;
};
int n;
bool cmp(Student a,Student b){
return a.grade<b.grade;
}
vector<Student> studentSet;
int main(){
cin>>n;
for(int i=0;i<n;i++){
Student s;
cin>>s.name>>s.gender;
cin>>s.id>>s.grade;
s.idd=i;
studentSet.push_back(s);
}
sort(studentSet.begin(),studentSet.end(),cmp);
int p=-1,q=-1;
for(int i=0;i<n;i++){
if(studentSet[i].gender[0]=='M'){
if(p==-1){p=i;}
}
if(studentSet[i].gender[0]=='F'){
q=i;
}
}
int flag=-1;
if(q==-1){
cout<<"Absent"<<endl;
flag=1;
}else{
cout<<studentSet[q].name<<" "<<studentSet[q].id<<endl;
}
if(p==-1){
cout<<"Absent"<<endl;
flag=1;
}else{
cout<<studentSet[p].name<<" "<<studentSet[p].id<<endl;
}
if(flag==-1){
cout<<(studentSet[q].grade-studentSet[p].grade)<<endl;
}else{
cout<<"NA"<<endl;
}
return 0;
}

PAT1036. Boys vs Girls (25)的更多相关文章

  1. PAT1036:Boys vs Girls

    1036. Boys vs Girls (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This ti ...

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

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

  3. PAT 1036 Boys vs Girls (25 分)

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

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

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

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

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

  6. PAT 1036 Boys vs Girls (25分) 比大小而已

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

  7. 1036. Boys vs Girls (25)

    #include <stdio.h>#include <string.h>int main(){ int n,i; while(scanf("%d",&am ...

  8. PAT甲题题解-1036. Boys vs Girls (25)-找最大最小,大水题

    题意:给出n个人的姓名.性别.ID.分数,让你找出其中哪个妹纸分数最高.哪个汉子分数最低.以及他们的差如果没有妹纸或者汉子,则对应输出Absent,差用NA代替. 就是for一遍找最大最小值,水题 # ...

  9. 1036 Boys vs Girls (25)(25 point(s))

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

随机推荐

  1. angular_文本变化

    注意,在input中用ng-change的时候,一定要结合着ng-model用 开头,注意在这里添加了ng-app <!DOCTYPE html> <html lang=" ...

  2. 调试SVO_edgelet

    感谢白巧克力亦唯心提供的SVO_edgelet代码,作者博客:https://blog.csdn.net/heyijia0327/article/details/61682150 程序地址: http ...

  3. php 正则表达式三.模式修正

    1.贪婪模式和懒惰模式, 贪婪模式:php中正则默认是贪婪模式,匹配尽可能多 的字符,比如 $pattern='/a+b/'; $subject='aaaaaaaaab,那么可能会preg_match ...

  4. When an HTTP server receives a request for a CGI script

    cgicc: Overview of the Common Gateway Interface https://www.gnu.org/software/cgicc/doc/cgi_overview. ...

  5. Spring - Netty (整合)

      写在前面  ​ 大家好,我是作者尼恩.目前和几个小伙伴一起,组织了一个高并发的实战社群[疯狂创客圈].正在开始 高并发.亿级流程的 IM 聊天程序 学习和实战,此文是:   疯狂创客圈 Java ...

  6. List、Map、Set三个接口,存取元素时,各有什么特点?

    List与Set都是单列元素的集合,它们有一个功共同的父接口Collection. Set里面不允许有重复的元素, 存元素:add方法有一个boolean的返回值,当集合中没有某个元素,此时add方法 ...

  7. 转!!java泛型

    介绍java泛型的一篇文章,通俗易懂! 原文地址:http://www.cnblogs.com/lwbqqyumidi/p/3837629.html 一. 泛型概念的提出(为什么需要泛型)? 首先,我 ...

  8. 003-linux安装软件的几种方法

    一.rpm包安装方式步骤 1.找到相应的软件包,比如soft.version.rpm,下载到本机某个目录: 2.打开一个终端,su -成root用户: 3.cd soft.version.rpm所在的 ...

  9. zz Qt下 QString转char*和char []

    以下内容为转载:http://www.cnblogs.com/Romi/archive/2012/03/12/2392478.html -------------------------------- ...

  10. discuz手机版图片缩略图大小设置/修改清晰度

    discuz手机版 图片缩略图大小设置/修改清晰度 \template\default\mobile\forum\discuzcode.htm和 \template\default\touch\for ...