当前位置:网站首页>1036 Boys vs Girls
1036 Boys vs Girls
2022-07-02 05:33:00 【Brosto_Cloud】
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.
Input Specification:
Each input file contains one test case. Each case contains a positive integer N, followed by N lines of student information. Each line contains a student's name, gender, ID and grade, separated by a space, where name and ID are strings of no more than 10 characters with no space, gender is either F (female) or M (male), and grade is an integer between 0 and 100. It is guaranteed that all the grades are distinct.
Output Specification:
For each test case, output in 3 lines. The first line gives the name and ID of the female student with the highest grade, and the second line gives that of the male student with the lowest grade. The third line gives the difference gradeF−gradeM. If one such kind of student is missing, output Absent in the corresponding line, and output NA in the third line instead.
Sample Input 1:
3
Joe M Math990112 89
Mike M CS991301 100
Mary F EE990830 95
Sample Output 1:
Mary EE990830
Joe Math990112
6
Sample Input 2:
1
Jean M AA980920 60
Sample Output 2:
Absent
Jean AA980920
NA#include <iostream>
#include <string>
using namespace std;
int main() {
int n, fmax = -1, mmin = 101, score;
string fName, fId, mName, mId, name, gender, id;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> name >> gender >> id >> score ;
if (score > fmax && gender == "F") {
fName = name;
fId = id;
fmax = score;
}
if (score < mmin && gender == "M") {
mName = name;
mId = id;
mmin = score;
}
}
bool flag = 0;
if (fmax == -1) {
cout << "Absent" << endl;
flag = 1;
} else {
cout << fName << ' ' << fId << endl;
}
if (mmin == 101) {
cout << "Absent" << endl;
flag = 1;
} else {
cout << mName << ' ' << mId << endl;
}
if (flag) {
cout << "NA";
} else {
cout << fmax - mmin;
}
return 0;
}
边栏推荐
- Sliding window on the learning road
- Global and Chinese market of cell culture freezers 2022-2028: Research Report on technology, participants, trends, market size and share
- php/js cookie共享跨域的问题
- 操作符详解
- idea开发工具常用的插件合集汇总
- 【技术随记-08】
- Gee: find the spatial distribution and corresponding time of the "greenest" in the Yellow River Basin in 2020 [pixel by pixel analysis]
- Fabric.js 激活输入框
- Global and Chinese market of pressure gauges 2022-2028: Research Report on technology, participants, trends, market size and share
- 生成二维码
猜你喜欢
随机推荐
Pytorch Chinese document
Get the details of the next largest number
Global and Chinese markets of semiconductor laser therapeutics 2022-2028: Research Report on technology, participants, trends, market size and share
Brew install * failed, solution
Gee series: unit 7 remote sensing image classification using GEE [random forest classification]
Fabric.js 基础笔刷
Nodejs (02) - built in module
"Original, excellent and vulgar" in operation and maintenance work
Zzuli:1069 learn from classmate Z
ThreadLocal memory leak
2022-2-14 learning xiangniuke project - Section 7 account setting
延时队列两种实现方式
[golang syntax] be careful with the copy of slices
简单封装 js并应用
6.网络-基础
来啦~ 使用 EasyExcel 导出时进行数据转换系列新篇章!
Disable access to external entities in XML parsing
Fabric.js 圆形笔刷
[personal test] copy and paste code between VirtualBox virtual machine and local
Online music player app

![Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]](/img/7b/b9ef76cee8b32204331a9c3c21b5c2.jpg)







