#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. 【APIO2014】Palindromes

    #103. [APIO2014]Palindromes 统计 描述 提交 自定义测试 给你一个由小写拉丁字母组成的字符串 ss.我们定义 ss 的一个子串的存在值为这个子串在 ss 中出现的次数乘以这 ...

  2. ionicframework I ------------- 初体验

    ionicframework I -------------  初体验 Create hybrid mobile apps with the web technologies you love. Fr ...

  3. [LintCode] 有效回文串

    class Solution { public: /** * @param s A string * @return Whether the string is a valid palindrome ...

  4. angular的过滤器

    angular有一些自带的过滤器,今天我就来写一下. 首先还是先把导入一个angular插件,再在我们的js中把模块和控制台写上(别忘了在html中写入模块名和在body中写入控制台名,当然控制台名可 ...

  5. Django 中的自定义分页标签

    目录结构: 1.在应用下,migrations的同级目录创建templatetags目录(主要两个文件,包含__init__.py) 2.创建分页标签(pagetag.py) #!/usr/bin/e ...

  6. 改变label中的某字体颜色

    NSString *allString=@"你家在哪里,需要我送你么"; NSString *subString=@"在哪里"; UILabel *string ...

  7. 实践中需要了解的cpu特性

    目录 分段机制 特权级检查 GDT和LDT 堆栈切换 分页机制 中断 分段机制 实模式中cs是一个实实在在的段首地址,ip为cs所指向段的偏移,所以cs<<4+ip是当前cpu执行的指令. ...

  8. 前端基础-css(2)

    一.标准文档流 宏观的将,我们的web页面和ps等设计软件有本质的区别,web网页的制作,是个“流”,从上而下,像 “织毛衣”.而设计软件 ,想往哪里画东西,就去哪里画. 标准文档流下,有一些现象,比 ...

  9. Java Concurrent happens-before

    happens-before relation on memory operations such as reads and writes of shared variables. The resul ...

  10. Memcached基础介绍

    1.memcached是什么,有什么作用? )memcached是一个开源的.高性能的内存的缓存软件,从名称上看mem就是内存的意思,而cache就是缓存的意思. )memcached通过在事先规划好 ...