AcWing 1520. 男孩 vs 女孩
原题链接
简单
作者:
og_
,
2020-05-26 18:37:42
,
所有人可见
,
阅读 413
C++ 代码
#include<bits/stdc++.h>
using namespace std;
map<string,pair<string,int>> mp;
int main(){
int n;
cin>>n;
int f_max=-1,m_min=110;
string f_max_id="",m_min_id="";
while(n--){
string s1,s2,s3;
int score;
cin>>s1>>s2>>s3>>score;
mp[s1] = {s3,score};
if(s2=="M"){
if(score<m_min) {
m_min = score;
m_min_id=s1;
}
}
else if(s2=="F"){
if(score>f_max) {
f_max = score;
f_max_id=s1;
}
}
}
int num = f_max - m_min;
if(f_max_id==""&&m_min_id!=""){
cout<<"Absent"<<endl<<m_min_id<<" "<<mp[m_min_id].first<<endl<<"NA";
}
else if(f_max_id!=""&&m_min_id==""){
cout<<f_max_id<<" "<<mp[f_max_id].first<<endl<<"Absent"<<endl<<"NA";
}
else{
cout<<f_max_id<<" "<<mp[f_max_id].first<<endl;
cout<<m_min_id<<" "<<mp[m_min_id].first<<endl<<num;
}
return 0;
}