#include<bits/stdc++.h>
using namespace std;
int main()
{
string chotto = "", boro = "", st;
int n, i, year, month, day, cyear, cmonth, cday, byear, bmonth, bday;
cyear = cmonth = cday = -1000000;
byear = bmonth = bday = 1000000;
cin >> n;
for(i=1; i<=n; i++)
{
cin >> st >> day >> month >> year;
if(year > cyear)
{
chotto = st;
cyear = year;
cmonth = month;
cday = day;
}
else if(year == cyear)
{
if(month > cmonth)
{
chotto = st;
cyear = year;
cmonth = month;
cday = day;
}
else if(month == cmonth)
{
if(day > cday)
{
chotto = st;
cyear = year;
cmonth = month;
cday = day;
}
}
}
if(year < byear)
{
boro = st;
byear = year;
bmonth = month;
bday = day;
}
else if(year == byear)
{
if(month < bmonth)
{
boro = st;
byear = year;
bmonth = month;
bday = day;
}
else if(month == bmonth)
{
if(day < bday)
{
boro = st;
byear = year;
bmonth = month;
bday = day;
}
}
}
}
cout << chotto << "\n";
cout << boro << "\n";
return 0;
}
using namespace std;
int main()
{
string chotto = "", boro = "", st;
int n, i, year, month, day, cyear, cmonth, cday, byear, bmonth, bday;
cyear = cmonth = cday = -1000000;
byear = bmonth = bday = 1000000;
cin >> n;
for(i=1; i<=n; i++)
{
cin >> st >> day >> month >> year;
if(year > cyear)
{
chotto = st;
cyear = year;
cmonth = month;
cday = day;
}
else if(year == cyear)
{
if(month > cmonth)
{
chotto = st;
cyear = year;
cmonth = month;
cday = day;
}
else if(month == cmonth)
{
if(day > cday)
{
chotto = st;
cyear = year;
cmonth = month;
cday = day;
}
}
}
if(year < byear)
{
boro = st;
byear = year;
bmonth = month;
bday = day;
}
else if(year == byear)
{
if(month < bmonth)
{
boro = st;
byear = year;
bmonth = month;
bday = day;
}
else if(month == bmonth)
{
if(day < bday)
{
boro = st;
byear = year;
bmonth = month;
bday = day;
}
}
}
}
cout << chotto << "\n";
cout << boro << "\n";
return 0;
}
Comments
Post a Comment