AcWing 1478. 签到与签出
原题链接
简单
作者:
eveer
,
2021-08-26 19:55:17
,
所有人可见
,
阅读 160
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct people
{
string id;
int in,out;//in表示上班的时间,out表示下班时间
}peo[N];
int get_time(string time)//将文本形式的时间转化为秒
{
int res=0;
res+=(time[0]-'0')*10*3600;
res+=(time[1]-'0')*3600;
res+=(time[3]-'0')*10*60;
res+=(time[4]-'0')*60;
res+=(time[3]-'0')*10;
res+=(time[4]-'0');
return res;
}
bool incmp(people x,people y)
{
return x.in<y.in;
}
bool outcmp(people x,people y)
{
return x.out>y.out;
}
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
string id,begin,end;
cin>>id>>begin>>end;
peo[i].id=id;
peo[i].in=get_time(begin);
peo[i].out=get_time(end);
}
sort(peo,peo+n,incmp);
cout<<peo[0].id<<' ';
sort(peo,peo+n,outcmp);
cout<<peo[0].id<<endl;
return 0;
}