-
Notifications
You must be signed in to change notification settings - Fork 2
/
B1028.cpp
62 lines (57 loc) · 1.32 KB
/
B1028.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
#include <cstdio>
#include <cstring>
//using namespace std;
struct persion{
char name[8];
int year;
int month;
int day;
bool operator <= (const persion &p) const{
if(year < p.year) return true;
else if(year == p.year && month < p.month) return true;
else if(year == p.year && month == p.month && day <= p.day) return true;
return false;
}
bool operator >= (const persion &p) const{
if(year > p.year) return true;
else if(year == p.year && month > p.month) return true;
else if(year == p.year && month == p.month && day >= p.day) return true;
return false;
}
persion &operator = (const persion &p){
if(this == &p)
return *this;
strcpy(name, p.name);
year = p.year;
month = p.month;
day = p.day;
return *this;
}
};
int main(){
int n;
persion tmp, max, min, low_bound, up_bound;
up_bound.year = 2014; low_bound.year = 1814;
up_bound.month = low_bound.month = 9;
up_bound.day = low_bound.day = 6;
max = low_bound;
min = up_bound;
scanf("%d", &n);
int valid_count = 0;
while(n--){
scanf("%s %d/%d/%d", tmp.name, &tmp.year, &tmp.month, &tmp.day);
if(tmp >= low_bound && tmp <= up_bound){
++valid_count;
if(tmp >= max)
max = tmp;
if(tmp <= min)
min = tmp;
}
}
printf("%d", valid_count);
if(valid_count > 0){
printf(" %s", min.name);
printf(" %s", max.name);
}
return 0;
}