-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1036.cpp
84 lines (83 loc) · 1.34 KB
/
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
class Node
{
public:
char name[11];
char id[11];
int grade;
bool operator<(const Node & right) const
{
return grade<right.grade;
}
};
int main()
{
freopen("input.in","r",stdin);
freopen("output.out","w",stdout);
int n,i;
scanf("%d",&n);
vector<Node> mv;
vector<Node> fv;
for(i=0;i<n;i++)
{
char name[11];
char id[11];
char gender[2];
int grade;
scanf("%s%s%s%d",name,gender,id,&grade);
if(strcmp(gender,"M") == 0)
{
Node r;
strcpy(r.id,id);
strcpy(r.name,name);
r.grade=grade;
mv.push_back(r);
}
else
{
Node r;
strcpy(r.id,id);
strcpy(r.name,name);
r.grade=grade;
fv.push_back(r);
}
}
bool haveM,haveF;
int max,min;
if(fv.size()==0)
{
haveF=false;
printf("Absent\n");
}
else
{
haveF=true;
sort(fv.begin(),fv.end());
max=fv[fv.size()-1].grade;
printf("%s %s\n",fv[fv.size()-1].name,fv[fv.size()-1].id);
}
if(mv.size()==0)
{
haveM=false;
printf("Absent\n");
}
else
{
haveM=true;
sort(mv.begin(),mv.end());
min=mv[0].grade;
printf("%s %s\n",mv[0].name,mv[0].id);
}
if(haveM && haveF)
printf("%d",max-min);
else
printf("NA");
return 0;
}