#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct Student{
	string name;
	string gender;
	string id;
	int grade;
	int idd;
};
int n;
bool cmp(Student a,Student b){
	return a.grade<b.grade;
}
vector<Student> studentSet;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		Student s;
		cin>>s.name>>s.gender;
		cin>>s.id>>s.grade;
		s.idd=i;
		studentSet.push_back(s);
	}
	sort(studentSet.begin(),studentSet.end(),cmp);
	int p=-1,q=-1;
	for(int i=0;i<n;i++){
		if(studentSet[i].gender[0]=='M'){
			if(p==-1){p=i;}
		}
		if(studentSet[i].gender[0]=='F'){
			q=i;
		}
	}
	int flag=-1;
	if(q==-1){
		cout<<"Absent"<<endl;
		flag=1;
	}else{
		cout<<studentSet[q].name<<" "<<studentSet[q].id<<endl;
	}
	if(p==-1){
		cout<<"Absent"<<endl;
		flag=1;
	}else{
		cout<<studentSet[p].name<<" "<<studentSet[p].id<<endl;
	}
	if(flag==-1){
		cout<<(studentSet[q].grade-studentSet[p].grade)<<endl;
	}else{
		cout<<"NA"<<endl;
	}
    return 0;
}

 

相关文章:

  • 2020-06-02
  • 2022-12-23
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2021-05-18
猜你喜欢
  • 2021-12-26
  • 2021-09-06
  • 2021-06-07
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案