模拟题
#include <bits/stdc++.h>
using namespace std;
struct S
{
string name, gender, ID;
int grade;
void read()
{
cin >> name >> gender >> ID >> grade;
}
};
vector<S> a;
int main()
{
int N;
scanf("%d\n", &N);
a.resize(N);
S ansM, ansF;
ansM.grade = INT_MAX;
ansF.grade = INT_MIN;
for (int i = 0; i < N; i++) {
a[i].read();
if (a[i].gender == "M" && a[i].grade < ansM.grade) ansM = a[i];
else if (a[i].gender == "F" && a[i].grade > ansF.grade) ansF = a[i];
}
bool flag = true;
if (ansF.grade == INT_MIN) cout << "Absent" << endl, flag = false; else cout << ansF.name << ' ' << ansF.ID << endl;
if (ansM.grade == INT_MAX) cout << "Absent" << endl, flag = false; else cout << ansM.name << ' ' << ansM.ID << endl;
if (flag) cout << ansF.grade - ansM.grade << endl; else cout << "NA" << endl;
}