这种排序查找的题太多了
对于我现阶段来说并没有特别大的提升,但是为了提交AC时爽一下,我还是再刷了一遍。
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
string namef,idf,namem,idm,name,id;
char sex;
int grade,gradem=101,gradef=-1;
for(int i=0;i<n;i++){
cin>>name>>sex>>id>>grade;
if(sex=='M'){
if(grade < gradem){
gradem = grade;
namem = name;
idm = id;
}
}else{
if(grade > gradef){
gradef = grade;
namef = name;
idf = id;
}
}
}
if(gradef==-1) cout<<"Absent"<<endl;
else cout<<namef<<" "<<idf<<endl;
if(gradem==101) cout<<"Absent"<<endl;
else cout<<namem<<" "<<idm<<endl;
if(gradef==-1 || gradem==101) cout<<"NA"<<endl;
else cout<<gradef-gradem<<endl;
return 0;
}