AcWing 1520. 男孩 vs 女孩
原题链接
简单
作者:
李sir
,
2021-03-18 15:56:05
,
所有人可见
,
阅读 239
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
string girl_name,girl_id,boy_id,boy_name;
int boy_score,girl_score;
for(int i=0;i<n;i++)
{
string id,sex,name;
int score;
cin>>name>>sex>>id>>score;
if(sex=="F")
{
if(girl_name.empty()||girl_score<score)
{
girl_score=score;
girl_name=name;
girl_id=id;
}
}else
{
if(boy_name.empty()||boy_score>score)
{
boy_score=score;
boy_name=name;
boy_id=id;
}
}
}
if(girl_name.empty()) puts("Absent");
else cout<<girl_name<<' '<<girl_id<<endl;
if(boy_name.empty()) puts("Absent");
else cout<<boy_name<<' '<<boy_id<<endl;
if(girl_name.size()&&boy_name.size())
{
printf("%d",girl_score-boy_score);
}else puts("NA");
return 0;
}