输入输出,利用字符串可以简单很多。
#include<iostream>
#include<string>
#include<map>
using namespace std;
map<string, string>M1, M2;
int main() {
int N;
string name, intime, outime;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> name >> intime >> outime;
M1[intime] = name;
M2[outime] = name;
}
cout << M1.begin()->second << " " << M2.rbegin()->second;
return 0;
}