题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1006
开门人关门人,时间是可以按字符串直接比较的,直接排序。
// sort
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define SIZE 1000
using namespace std;
struct Node
{
string id;
string ct;
string lt;
};
bool cmp0(Node x, Node y)
{
return x.ct<y.ct;
}
bool cmp1(Node x, Node y)
{
return x.lt>y.lt;
}
int main()
{
int m;
scanf("%d", &m);
Node ary[SIZE];
string id, ctime, ltime;
for(int i=0; i<m; i++)
{
cin >> ary[i].id >> ary[i].ct >> ary[i].lt;
}
sort(ary, ary+m, cmp0);
cout << ary[0].id << " ";
sort(ary, ary+m, cmp1);
cout << ary[0].id << endl;
return 0;
}