当前位置:网站首页>1036 Boys vs Girls
1036 Boys vs Girls
2022-07-02 05:37: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;
}
边栏推荐
- Fabric.js 更换图片的3种方法(包括更换分组内的图片,以及存在缓存的情况)
- centos8安装mysql8.0.22教程
- Fabric. JS centered element
- Gee series: unit 9 generate sampling data in GEE [random sampling]
- 2022-2-14 learning xiangniuke project - Section 7 account setting
- Installation du tutoriel MySQL 8.0.22 par centos8
- I want to understand the swift code before I learn it. I understand it
- Zzuli:1069 learn from classmate Z
- Gee: find the spatial distribution and corresponding time of the "greenest" in the Yellow River Basin in 2020 [pixel by pixel analysis]
- Zzuli:1060 numbers in reverse order
猜你喜欢
Gee series: Unit 3 raster remote sensing image band characteristics and rendering visualization
Nodejs (02) - built in module
Gee data set: export the distribution and installed capacity of hydropower stations in the country to CSV table
Appnuim environment configuration and basic knowledge
Installation du tutoriel MySQL 8.0.22 par centos8
Innovation never stops -- the innovation process of nvisual network visualization platform for Excel import
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]
【pyinstaller】_get_sysconfigdata_name() missing 1 required positional argument: ‘check_exists‘
Fabric. JS gradient
A collection of commonly used plug-ins for idea development tools
随机推荐
php/js cookie共享跨域的问题
Fabric.js 更换图片的3种方法(包括更换分组内的图片,以及存在缓存的情况)
MySQL foundation --- query (learn MySQL foundation in 1 day)
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
Visual studio import
Global and Chinese markets of semiconductor laser therapeutics 2022-2028: Research Report on technology, participants, trends, market size and share
Gee: use of common mask functions in remote sensing image processing [updatemask]
Pytorch Chinese document
idea开发工具常用的插件合集汇总
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]
Fabric. JS iText sets the color and background color of the specified text
记录sentry的踩坑之路
Zzuli:1061 sequential output of digits
Fabric.js 将本地图像上传到画布背景
如何写出好代码 — 防御式编程指南
Generate QR code
Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]
Ls1046nfs mount file system
Applet jumps to official account
Zzuli:1060 numbers in reverse order