当前位置:网站首页>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;
}
边栏推荐
- ERP management system development and design existing source code
- Gee dataset: chirps pentad high resolution global grid rainfall dataset
- Gee: use of common mask functions in remote sensing image processing [updatemask]
- Php/js cookie sharing across domains
- Fabric. JS 3 APIs to set canvas width and height
- 2022-2-14 learning xiangniuke project - Section 6 displays login information
- Fabric. JS iText superscript and subscript
- Zzuli:1064 encrypted characters
- Fabric.js 自由绘制矩形
- Visual studio import
猜你喜欢
idea开发工具常用的插件合集汇总
"Original, excellent and vulgar" in operation and maintenance work
Basic use of form
ThreadLocal memory leak
Record sentry's path of stepping on the pit
idea開發工具常用的插件合集匯總
Appnuim environment configuration and basic knowledge
Gee series: unit 6 building various remote sensing indexes in Google Earth engine
Operator details
brew install * 失败,解决方法
随机推荐
Gee series: Unit 1 Introduction to Google Earth engine
Fabric. JS three methods of changing pictures (including changing pictures in the group and caching)
How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure
2022-2-14 learning xiangniuke project - Section 6 displays login information
Fabric. JS right click menu
Gee: analyze the change of spatial centroid of remote sensing image [centroid acquisition analysis]
延时队列两种实现方式
Zzuli:1065 count the number of numeric characters
Fabric.js IText设置指定文字的颜色和背景色
Disable access to external entities in XML parsing
Gee series: Unit 3 raster remote sensing image band characteristics and rendering visualization
Win10 copy files, save files... All need administrator permission, solution
Global and Chinese markets for marine selective catalytic reduction systems 2022-2028: Research Report on technology, participants, trends, market size and share
Here comes a new chapter in the series of data conversion when exporting with easyexcel!
Global and Chinese markets of semiconductor laser therapeutics 2022-2028: Research Report on technology, participants, trends, market size and share
Gee series: unit 7 remote sensing image classification using GEE [random forest classification]
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
小程序跳装到公众号
记录sentry的踩坑之路
Common protocols and download paths of NR