【PAT甲级】1036 Boys vs Girls (25 分)
题意:
输入一个正整数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 分)的更多相关文章
- PAT 甲级 1036 Boys vs Girls (25 分)(简单题)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade ...
- 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 ...
- PAT甲级:1036 Boys vs Girls (25分)
PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...
- PAT 1036 Boys vs Girls (25 分)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade ...
- 1036 Boys vs Girls (25分)(水)
1036 Boys vs Girls (25分) This time you are asked to tell the difference between the lowest grade o ...
- 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 ...
- PAT 1036 Boys vs Girls (25分) 比大小而已
题目 This time you are asked to tell the difference between the lowest grade of all the male students ...
- 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 ...
- PAT 甲级 1036 Boys vs Girls(20)
https://pintia.cn/problem-sets/994805342720868352/problems/994805453203030016 This time you are aske ...
随机推荐
- ARM64架构下面安装mysql5.7.22
MySQL下载地址为: https://obs.cn-north-4.myhuaweicloud.com/obs-mirror-ftp4/database/mysql-5.7.27-aarch64.t ...
- Win10-IIS注册asp 此操作系统版本不支持此选项 错误解决方法
现象再现: 今日在Win10上面ASP.NET网站突然不能跑了, 过程再现: 根据资料提示重新注册ASPNET_IIS.exe -i 直接提示: C:\WINDOWS\system32>c:\w ...
- 2、json教程
JSON(JavaScript)对象表示法是一种轻量级的基于文本的开放标准, 被设计用于可读的数据交换, 约定使用JSON的程序包括 C C++ Java Python Perl 总结 JSO ...
- [C/C++] _tprintf() 输出不了汉字
在前面加一个 setlocale(LC_ALL, ""); //必须得有这行 否则不能输出中文 注意得加locale头文件 #include<stdio.h> #inc ...
- cmake 单个目录多个文件的情况
参考:https://www.hahack.com/codes/cmake/# 源文件一共有三个:main.cpp.MathFunctions.h.MathFunctions.cpp 文件内容分别如下 ...
- 【转】Docker网络模式--默认模式bridge模式
一 引言 当 Docker 启动时,会自动在主机上创建一个名为 docker0 虚拟网桥,这实际上就是 Linux 的一个 bridge,可以理解为一个软件交换机.它会在挂载到它的网口之间进行转发.系 ...
- 解决1130-host'192.168.2.137'is not allowed to connect to this mysql server报错问题
连接数据库服务器出现1130-host'192.168.2.137'is not allowed to connect to this mysql server错误, 这个问题是因为在数据库服务器中的 ...
- python练习:斐波那契数列的递归实现
python练习:斐波那契数列的递归实现 重难点:递归的是实现 def fib(n): if n==0 or n==1: return 1 else: return fib(n-1)+fib(n-2) ...
- mongodb 用户指引
维护人:陈权 一.mongodb install on linuxcurl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6 ...
- cookie,session,localStorage和sessionStorage
cookies:存储于浏览器端的数据.可以设置 cookies 的Max-Age或者Expires到期时间,如果不设置时间,则在浏览器关闭窗口的时候会消失. session:存储于服务器端的数据.se ...