【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 ...
随机推荐
- js 设计模式:观察者和发布订阅模式
总是把这两个当作同一个模式,但其实是不太一样的,现在重温一下. 观察者模式 观察者直接订阅目标,当目标触发事件时,通知观察者进行更新 简单实现 class Observer { constructor ...
- cent os 7.3修改mac地址方法
一.修改MAC地址方法 linux环境下: 需要用 #ifconfig eth0 down 先把网卡禁用 再用ifconfig eth0 hw ether 1234567890ab ...
- wordpress 支持上传中文名称文件
添加文章难免要传个图.文件啥的,可是呢,上传中文名称的文件竟然不行,找了半天,中文乱码,脑残了,竟然忘了这个事,哎 修改其实很简单,只需要两步 1./wp-admin/includes/file.ph ...
- Kubernetes(k8s)完整安装教程
Kubernetes(k8s)完整安装教程 2019-08-27 2.3k 记录 发表评论 目录 1 安装 1.1 安装 Docker 1.2 安装 VirtualBox 1.3 安装 kubect ...
- 技术学习的网站 http://www.runoob.com/
菜鸟教程:http://www.runoob.com/ W3C:https://www.w3cschool.cn/tutorial 脚本之家:https://www.jb51.net/
- 16,div+css的布局较table布局有什么优点?
改版的时候更加方便,只要改css文件 页面加载速度更快,结构化清晰,页面显示简洁 表现与结构相分离 易于搜索引擎优化,排名更靠前
- centos610无桌面安装libreoffice
Centos610系列配置 #安装文件 yum -y install libreoffice #安装中文包 yum -y install libreoffice-langpack-zh-Han* #安 ...
- 《掌握融资必备知识》---创业学习---训练营第一课---HHR---
一,<开始学习> 1,四个思考题: (1)从你决定开始融资,到你拿到钱,你都需要经历哪些环节? (2)你知道投资机构内部的工作流程吗? (3)融资最好的时机是什么时候? (4)创投圈的专业 ...
- 如果谷歌浏览器突然打不开网页,而且显示:"网页可能暂时无法连接,或者它已永久性地移动到了新网址,返回ERR_TUNNEL_CONNECTION_FAILED",怎么办?用这个方法,亲试有效!!!
打开cmd: 依次输入: ipconfig /flushdnsnbtstat –rnetsh int ip resetnetsh winsock reset 效果图 然后我的浏览器就能正常使用了,很有 ...
- Update(stage3):第1节 redis组件:10、redis集群
10.redis集群 1.redis集群的介绍 Redis 集群是一个提供在多个Redis节点之间共享数据的程序集. Redis 集群并不支持同时处理多个键的 Redis 命令,因为这需要在多个节点间 ...