-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1006.cpp
79 lines (71 loc) · 1.62 KB
/
1006.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
class MyTime{
public:
int hour,minute,second;
bool operator <(const MyTime & 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;
}
};
class Record
{
public:
char name[20];
MyTime in,out;
void print()
{
printf("%s %d:%d:%d %d:%d:%d\n",name,in.hour,in.minute,in.second,out.hour,out.minute,out.second);
}
};
bool lessIn(const Record & r1, const Record & r2)
{
if(r1.in < r2.in)
return true;
return false;
}
bool lessOut(const Record & r1, const Record & r2)
{
if(r1.out < r2.out)
return true;
return false;
}
int main()
{
int n,i,h,m,s;
char str[20];
freopen("input.in","r",stdin);
freopen("output.out","w",stdout);
vector<Record> v;
scanf("%d",&n);
for(i=0;i<n;i++)
{
Record r;
scanf("%s",r.name);
scanf("%d:%d:%d",&h,&m,&s);
r.in.hour=h;
r.in.minute=m;
r.in.second=s;
scanf("%d:%d:%d",&h,&m,&s);
r.out.hour=h;
r.out.minute=m;
r.out.second=s;
v.push_back(r);
}
sort(v.begin(),v.end(),lessIn);
printf("%s ",v[0].name);
sort(v.begin(),v.end(),lessOut);
vector<Record>::iterator it=v.end();
it--;
printf("%s",it->name);
//v[0].print();
return 0;
}