-
Notifications
You must be signed in to change notification settings - Fork 2
/
A1006.cpp
45 lines (43 loc) · 997 Bytes
/
A1006.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
#include <cstdio>
#include <cstring>
using namespace std;
struct Time {
int hour;
int munite;
int second;
Time() : hour(0), munite(0), second(0) {}
Time(int h, int m, int s) : hour(h), munite(m), second(s) {}
bool operator < (const Time &t) const {
if (hour != t.hour) return hour < t.hour;
else if (munite != t.munite) return munite < t.munite;
else return second < t.second;
}
bool operator > (const Time &t) const {
return t < *this;
}
Time &operator = (const Time &t) {
hour = t.hour;
munite = t.munite;
second = t.second;
return *this;
}
};
int main() {
int n;
scanf("%d", &n);
char id[16], first_id[16], last_id[16];
Time in, out, first(23, 59, 59), last;
while (n--) {
scanf("%s %d:%d:%d %d:%d:%d", id, &in.hour, &in.munite, &in.second, &out.hour, &out.munite, &out.second);
if (in < first) {
first = in;
strcpy(first_id, id);
}
if (out > last) {
last = out;
strcpy(last_id, id);
}
}
printf("%s %s", first_id, last_id);
return 0;
}