艰难的英语单词: consistent 英 [kənˈsɪstənt] 连续的; 不矛盾的 adj.
题意: 一组进出记录,找出进来最早的,和出去最晚的,输出他们的姓名即可。
难点: 手速题。可惜了,居然写错了几个变量名。可耻。
Code:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define inf 10009
#define INF 0x3f3f3f3f
#define loop(x,y,z) for(x=y;x<z;x++)
struct Time
{
int hour,minute,second;
Time(){}
Time(int h,int m,int s):hour(h),minute(m),second(s)
{
}
bool operator<(const Time&t)const
{
if(hour<t.hour)return true;
else if(hour==t.hour&&minute<t.minute)return true;
else if(hour==t.hour&&minute==t.minute&&second<t.second)return true;
return false;
}
}first,last;//最早时间和最晚时间
string n_first,n_last;//最早时间和最晚时间的员工名字
int n;
void Input()
{
scanf("%d",&n);
int i;
int h,m,s;//时分秒
string name;
char c;//标点
//Init
first.hour=99;first.minute=99;first.second=99;//最早的初始化为最晚的
last.hour=0;last.minute=0;last.second=0;//最晚的初始化为最早的
loop(i,0,n)
{
cin>>name;
cin>>h>>c>>m>>c>>s;
Time come(h,m,s);
cin>>h>>c>>m>>c>>s;
Time go(h,m,s);
//Judge
if(come<first)
{
first=come;
n_first=name;
}
if(last<go)
{
last=go;
n_last=name;
}
}
}
void Output()
{
cout<<n_first<<" "<<n_last<<endl;
}
int main()
{
Input();
Output();
return 0;
}