题意:

输入一个正整数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. Linux按文件名搜索命令

    find 搜索目录 -name 目标名字 find / -name file名 /代表是全盘搜索,也可以指定目录搜索 find 搜索文件的命令格式: find [搜索范围] [匹配条件] 选项: -n ...

  2. Azure IoT Hub 十分钟入门系列 (4)- 实现从设备上传日志文件/图片到 Azure Storage

    本文主要分享一个案例: 10分钟内通过Device SDK上传文件到IoTHub B站视频:https://www.bilibili.com/video/av90224073/ 本文主要有如下内容: ...

  3. python3中的正则表达式

    精确匹配: \d: 匹配一个数字     \w: 匹配一个字母或数字     . : 匹配任意一个字符     \s: 匹配一个空格(包括tab等空白符) 匹配变长的字符:     * : 匹配任意个 ...

  4. Reverse-Encrypted-Shell-via-Openssl

    目录 0x01 简介 0x02 使用openssl反弹加密shell 0x01 简介 使用常规NC或者其他常规的方法反弹shell,由于流量都是明文的,很容易被网络防御设备检测到,因此需要对传输内容进 ...

  5. 介绍Mobility Group

    Mobility或Roaming是无线客户端能够安全地从一个AP无缝关联到另一个AP的能力,并且延迟尽可能的短. 当无线客户端和AP关联并通过AP进行身份验证时,注册AP的WLC会将客户端条目放在自己 ...

  6. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) - D2. Optimal Subsequences (Hard Version)(主席树)

    题意:一共有$n$个数,$m$次询问,每次询问包括$k.pos$两个数,需要你从这$n$个数里面找出$k$个数,使得他们的总和最大,如果有多种情况,找出序号字典序最小的一组,然后输出这个序列中第$po ...

  7. 《掌握融资必备知识》---创业学习---训练营第一课---HHR---

    一,<开始学习> 1,四个思考题: (1)从你决定开始融资,到你拿到钱,你都需要经历哪些环节? (2)你知道投资机构内部的工作流程吗? (3)融资最好的时机是什么时候? (4)创投圈的专业 ...

  8. 17 JavaScript Cookies

    关于Cookie: Cookie是存储在电脑上的文本文件中的一些数据 Cookie致力于解决如何在连接关闭后记录客户单的用户信息 Cookie以键值对的形式存储,例如username=John Doe ...

  9. Hibernate学习(二)

    持久化对象的声明周期 1.Hibernate管理的持久化对象(PO persistence object )的生命周期有四种状态,分别是transient.persistent.detached和re ...

  10. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 网格系统实例:响应式的列重置

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