-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYOUNGCLA - Birthdates.cpp
More file actions
91 lines (86 loc) · 1.63 KB
/
YOUNGCLA - Birthdates.cpp
File metadata and controls
91 lines (86 loc) · 1.63 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
#include<bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Ford(i, a, b) for(int i = a; i >= b; i--)
#define ll long long
#define here cout<<"i am here"<<endl;
const long long base= 1e9 + 7;
const int maxn = 1000000;
struct classmate{
int dd;
int mm;
int yy;
};
int main(void){
ios::sync_with_stdio(false);
string s[103];
classmate a[103];
int n,max=0,min=maxn,key1,key2,k1 = 1, k2 = 1, b[103];
int j = 1,c[103],x=1,d[103],e[103];
cin>>n;
For(i, 1, n){
cin>>s[i];
cin>>a[i].dd>>a[i].mm>>a[i].yy;
if(a[i].yy > max) max = a[i].yy;
if(a[i].yy < min) min = a[i].yy;
}
For(i, 1, n){
if(a[i].yy == max){
b[j] = i;
j++;
}
if(a[i].yy == min){
c[x] = i;
x++;
}
}
if(j == 2) cout<<s[b[1]]<<endl;
if(j != 2){
max = 0;
For(i, 1, j-1){
if(a[b[i]].mm > max) max = a[b[i]].mm;
}
For(i, 1, j -1){
if(a[b[i]].mm == max){
d[k1] = b[i];
k1++;
}
}
if(k1 == 2) cout<<s[d[1]]<<endl;
else{
max = 0;
For(i, 1, k1 - 1){
if(a[b[i]].dd > max){
max = a[d[i]].dd;
key1 = d[i];
}
}
cout<<s[key1]<<endl;
}
}
if(x == 2) cout<<s[c[1]]<<endl;
if(x != 2){
min = maxn;
For(i, 1, x-1){
if(a[c[i]].mm < min) min = a[c[i]].mm;
}
For(i, 1, x -1){
if(a[c[i]].mm == min){
e[k2] = c[i];
k2++;
}
}
if(k2 == 2) cout<<s[e[1]]<<endl;
else{
min = maxn;
For(i, 1, k2 - 1){
if(a[c[i]].dd < min){
min = a[e[i]].dd;
key2 = e[i];
}
}
cout<<s[key2]<<endl;
}
}
return 0;
}