-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpat_advance_1036.cpp
56 lines (53 loc) · 931 Bytes
/
pat_advance_1036.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct info{
string name, id;
char gender;
int score;
};
vector<info> v;
int main(){
int n, femalMax = -1, maleMin = 101, fNum = 0, mNum = 0;
cin >> n;
bool f = true;
info temp;
for (int i = 0; i < n; i++)
{
cin >> temp.name >> temp.gender >> temp.id >> temp.score;
if (temp.gender == 'M'){
if (temp.score < maleMin){
maleMin = temp.score;
mNum = i;
}
}
else{
if (temp.score > femalMax){
femalMax = temp.score;
fNum = i;
}
}
v.push_back(temp);
}
if (femalMax != -1){
cout << v[fNum].name <<' '<< v[fNum].id << endl;
}
else{
cout << "Absent"<<endl;
f = false;
}
if (maleMin != 101){
cout << v[mNum].name <<' '<< v[mNum].id << endl;
}
else{
cout << "Absent" << endl;
f = false;
}
if (f)
cout << v[fNum].score - v[mNum].score;
else
cout << "NA";
return 0;
}