#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#define N 10005
#define ll long long
using namespace std;
vector<int>m,f;
struct node
{
string s1,s2;
}p[105];
int main()
{
int n,i,j,x;
while(scanf("%d",&n)!=EOF)
{
string s,s1,s2;
for(i = 0;i<n;i++)
{
cin>>s1>>s>>s2>>x;
if(s == "M")m.push_back(x);
else f.push_back(x);
p[x].s1 = s1;
p[x].s2 = s2;
}
if(m.size())sort(m.begin(),m.end());
if(f.size())sort(f.begin(),f.end());
int last = f.size()-1;
if(f.size())cout<<p[f[last]].s1<<" "<<p[f[last]].s2<<endl;
else cout<<"Absent"<<endl;
if(m.size())cout<<p[m[0]].s1<<" "<<p[m[0]].s2<<endl;
else cout<<"Absent"<<endl;
if(!f.size()||!m.size())cout<<"NA"<<endl;
else cout<<f[last]-m[0]<<endl;
}
return 0;
}
pat1036 Boys vs Girls
最新推荐文章于 2023-08-05 20:20:11 发布