总体来讲思路就是把时间转为秒然后排序来确定是谁
#include <iostream>
#include <map>
#include <string.h>
#include <algorithm>
using namespace std;
map<int, string> the_in;
map<int, string> the_out;
int main()
{
int m;
cin>>m;
int *ins, *outs;
ins = new int[m];
outs = new int[m];
for(int i=0;i<m;i++)
{
char id[15], temp;
int in_h, in_m, in_s, out_h, out_m, out_s, in, out;
cin>>id
>>in_h>>temp>>in_m>>temp>>in_s
>>out_h>>temp>>out_m>>temp>>out_s;
in = in_h*60*60 + in_m*60 + in_s;
out = out_h*60*60 + out_m*60 + out_s;
string str = id;
the_in[in] = str;
the_out[out] = str;
ins[i] = in;
outs[i] = out;
}
sort(ins, ins+m);
sort(outs, outs+m);
char* lock = &the_in[ins[0]][0];
char* unlock = &the_out[outs[m-1]][0];
cout<<lock<<" "<<unlock;
system("pause");
return 0;
}