题意:

输入一个正整数N(题干没指出范围,默认1e5可以AC),接下来输入N行数据,每行包括一名学生的姓名,性别,学号和分数。输出三行,分别为最高分女性学生的姓名和学号,最低分男性学生的姓名和学号,前者减去后者的分数差。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
pair<int,int>female[],male[];
string name[],num[];
int point[];
char gender;
int cntf,cntm;
int main(){
int n;
cin>>n;
for(int i=;i<=n;++i){
cin>>name[i];
cin>>gender;
cin>>num[i];
cin>>point[i];
if(gender=='F')
female[++cntf]={point[i],i};
else if(gender=='M')
male[++cntm]={point[i],i};
}
sort(female+,female++cntf);
sort(male+,male++cntm);
if(!cntf)
cout<<"Absent"<<"\n";
else
cout<<name[female[cntf].second]<<" "<<num[female[cntf].second]<<"\n";
if(!cntm)
cout<<"Absent"<<"\n";
else
cout<<name[male[].second]<<" "<<num[male[].second]<<"\n";
if(!cntf||!cntm)
cout<<"NA";
else
cout<<point[female[cntf].second]-point[male[].second];
return ;
}

【PAT甲级】1036 Boys vs Girls (25 分)的更多相关文章

  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 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 ...

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

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

  4. PAT 1036 Boys vs Girls (25 分)

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

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

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

  6. 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 ...

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

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

  8. PAT (Advanced Level) Practice 1036 Boys vs Girls (25 分)

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

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

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

随机推荐

  1. Angular的启动过程

    我们知道由命令 ng new project-name,cli将会创建一个基础的angular应用,我们是可以直接运行起来一个应用.这归功与cli已经给我们创建好了一个根模块AppModule,而根模 ...

  2. 笔记本电脑插上耳机声音依然外放解决方法 为什么插入HDMI线,电脑的音响就没有声音了

    笔记本电脑插上耳机声音依然外放解决方法: 下载一个驱动大师,安装声卡驱动.(驱动人生安装的驱动有可能不能用) 为什么插入HDMI线,电脑的音响就没有声音了 参考:https://zhidao.baid ...

  3. 在linux下安装java(centos和ubuntu)

    在本地测试环境安装插件,发现还得用到java,虽说是个程序员,可是没用过java啊,哎,但是插件得用啊,怎么办啊?自己装呗 一.自己的系统:CentOS 7 1.查看CentOS自带JDK是否已安装. ...

  4. <img>标签在vue中的使用

    定义和用法 onerror 事件会在文档或图像加载过程中发生错误时被触发. 在装载文档或图像的过程中如果发生了错误,就会调用该事件句柄. 实例 加载缩略图 <img :src="'/x ...

  5. Jmeter_正则表达式

    元字符+限定符 元字符: . 任意字符 \d 任意单个数字 [0-9] 0-9 [a-z A-Z] 限定符 + 匹配至少大于1次 ? 匹配0次或者1次 * 匹配0次或者多次 {n}匹配n次 在线正则表 ...

  6. 【C语言】(for循环嵌套)找出1000以内的水仙花数

    什么是水仙花数? 水仙花数是指一个 3 位数,它的每个位上的数字的 3次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153). 分析: 根据定义可知: a*a*a+b*b*b+c*c*c ...

  7. 【MySQL】完整性约束

    " 目录 not null default unique 单列唯一 联合唯一 primary key 单列主键 复合主键 auto_increment 步长与偏移量 foreign key ...

  8. C语言:对传入sp的字符进行统计,三组两个相连字母“ea”"ou""iu"出现的次数,并将统计结果存入ct所指的数组中。-在数组中找出最小值,并与第一个元素交换位置。

    //对传入sp的字符进行统计,三组两个相连字母“ea”"ou""iu"出现的次数,并将统计结果存入ct所指的数组中. #include <stdio.h& ...

  9. 07-Docker-Image深入理解

    目录 07-Docker-Image深入理解 参考 镜像简介 什么是Docker镜像 什么是Docker容器 镜像结构 镜像特性 镜像层 容器层 镜像存储 07-Docker-Image深入理解 Do ...

  10. 2019牛客暑期多校训练营(第七场)A String (字符串的最小表示)

    思路 这题思路如果是递归的话,应该是比较正确的.但是实际上只用切割两次就可以了. 先把原串从后向前切割一次,再把每一部分切割一次. 切两次的思路实际上是有漏洞的. 递归的思路,终点是,如果串长为1,或 ...