一道sort水题
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1100;
struct node
{
string name;
int hh;
int mm;
int ss;
int beginTime;
int endTime;
}person[MAXN];
bool beginCmp(node a,node b)
{
return a.beginTime < b.beginTime;
}
bool endCmp(node a,node b)
{
return a.endTime > b.endTime;
}
int main(void)
{
freopen("pat0314/in.txt","r",stdin);
int n;
cin>>n;
for(int i = 0;i<n;i++)
{
string name;
int hh,mm,ss;
cin>>name;
scanf("%d:%d:%d",&hh,&mm,&ss);
person[i].name = name;
person[i].beginTime = hh * 3600 + mm * 60 + ss;
scanf("%d:%d:%d",&hh,&mm,&ss);
person[i].endTime = hh * 3600 + mm * 60 + ss;
}
sort(person,person + n,beginCmp);
cout<<person[0].name<<" ";
sort(person,person + n,endCmp);
cout<<person[0].name;
return 0;
}