AcWing 1520. 男孩 vs 女孩
原题链接
简单
作者:
Wegoon
,
2021-09-05 23:47:00
,
所有人可见
,
阅读 273
知识点:模拟、字符串处理
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
struct node {
string name, sex, id;
int num;
}ans1, ans2;
int main() {
ans1.num = -1, ans2.num = 101;
cin >> n;
for (int i =0; i < n; i ++ ) {
string a, b, c;
int d;
cin >> a >> b >> c >> d;
node x = {a, b, c, d};
if(b == "M" && d < ans2.num) ans2 = x;
else if(b == "F" && d > ans1.num) ans1 = x;
}
if(ans1.num == -1) cout<< "Absent" << endl;
else cout << ans1.name << ' ' << ans1.id << endl;
if(ans2.num == 101) cout<< "Absent" << endl;
else cout << ans2.name << ' ' << ans2.id << endl;
if(ans1.num == -1 || ans2.num == 101) cout << "NA" << endl;
else cout << ans1.num - ans2.num << endl;
return 0;
}