【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 ...
随机推荐
- Angular的启动过程
我们知道由命令 ng new project-name,cli将会创建一个基础的angular应用,我们是可以直接运行起来一个应用.这归功与cli已经给我们创建好了一个根模块AppModule,而根模 ...
- sqli-libs(5-10关)
Less_5 补充基础知识 1. left(a,b)左侧截取a的前b位,正确则返回1,错误则返回o Select left(database(),1)=’s’; 其中database()为sec ...
- vscode git连接github
上一篇文章中介绍了vscode中git的简单使用方法vscode git的简单使用 上次只讲到了本地库的创建,这次说明下怎么push到github上 首先需要有一个github的账号 github官 ...
- JavaScript 对象的深复制
对象的深复制 源对象的属性更改,不会引起复制后的对象个属性的更改 源对象的任何属性与子属性与新对象的之间没有任何引用关系 Coding: /* 对象的深复制: 1 初始化目标对象 如果没有指定目标对象 ...
- 浅析PHP页面局部刷新功能的实现小结(转)
转载地址 https://www.jb51.net/article/38901.htm 方法其实挺多的.以前比较常用的是iframe这样来做.现在多了个ajax,所以一般情况下都是用的ajax.第一种 ...
- 使用JavaScript获取样式的属性值
1 . 在js中可以使用style属性来获取样式的属性值(只能获取内联样式的属性值) 语法格式为: HTML元素.style.样式属性; 2 . 在IE浏览器中,使用currentStyle来获取 ...
- java基础数据类型和处理
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSON; import java.io.*; import j ...
- 商品呢拖拽到购物车,appendChild的剪切功能
今天来到了妙味课堂的html5课程的第2张的第8节,讲的是把商品拖拽到购物车的演示.其中有一个关于appendChild的使用,,每次拖拽都会触发这个方法,但是每次之后,却还是只有一个总价,好吧,说不 ...
- 「题解」「JOISC 2014 Day1」历史研究
目录 题目 考场思考 思路分析及标程 题目 点这里 考场思考 大概是标准的莫队吧,离散之后来一个线段树加莫队就可以了. 时间复杂度 \(\mathcal O(n\sqrt n\log n)\) . 然 ...
- HDU4280 Island Transport
ISAP求最大流模板 #include<cstdio> #include<cstring> #include<algorithm> #include<iost ...