当前位置:网站首页>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;
}
边栏推荐
- centos8安装mysql8.0.22教程
- ERP management system development and design existing source code
- Small and medium-sized projects to achieve certification and authorization of hand filter
- Importation de studio visuel
- Gee series: unit 7 remote sensing image classification using GEE [random forest classification]
- Opencv LBP features
- 【技术随记-08】
- Sliding window on the learning road
- Fabric. JS centered element
- Youth training camp -- database operation project
猜你喜欢
![Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]](/img/1e/cf0aa09c2fce2278386f12eae4a6cd.jpg)
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]
![[golang syntax] be careful with the copy of slices](/img/5e/1c82c58940939b94d03377ebdc03e3.jpg)
[golang syntax] be careful with the copy of slices

No logic is executed after the El form is validated successfully

7. Eleven state sets of TCP

Fabric. JS iText superscript and subscript

LS1046nfs挂载文件系统
![Gee: use of common mask functions in remote sensing image processing [updatemask]](/img/55/bf4ef5fc923242e72caab71f1a4e4b.jpg)
Gee: use of common mask functions in remote sensing image processing [updatemask]
![Gee series: unit 9 generate sampling data in GEE [random sampling]](/img/ff/edb27b40f63eca81c5683e81b2860b.jpg)
Gee series: unit 9 generate sampling data in GEE [random sampling]

“简单”的无限魔方

Fabric. JS upload local image to canvas background
随机推荐
Gee series: unit 6 building various remote sensing indexes in Google Earth engine
Usage record of vector
Small and medium-sized projects to achieve certification and authorization of hand filter
I want to understand the swift code before I learn it. I understand it
Fabric.js 将本地图像上传到画布背景
Principle and implementation of parallax effect
Fabric. JS three methods of changing pictures (including changing pictures in the group and caching)
Résumé de la collection de plug - ins couramment utilisée dans les outils de développement idea
青训营--数据库实操项目
Fabric. JS basic brush
视差特效的原理和实现方法
LS1046nfs挂载文件系统
Gee: create a new feature and set corresponding attributes
金融门户相关信息
[golang syntax] be careful with the copy of slices
Centos8 installation mysql8.0.22 tutorial
2022-2-14 learning xiangniuke project - Section 7 account setting
Gee series: unit 7 remote sensing image classification using GEE [random forest classification]
Nodejs (02) - built in module
数据的储存