#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int n;
int main(int argc, char **argv){
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
cin >> n;
vector<pair<pair<int, int>, pair<int, string>> > student(n); // 여러개 페어로 묶으려면 이렇게 해야
// 년, 월, 일, 이름
for(int i=0; i<n; i++){
cin >> student[i].second.second >> student[i].second.first >>
student[i].first.second >> student[i].first.first;
}
sort(student.begin(), student.end()); // 년월일 순 정렬
cout << student[n-1].second.second << "\n" << student[0].second.second;
return 0;
}
여러가지를 pair로 묶을 때, pair는 한 번에 두개씩 밖에 묶지 못하기 때문에 pair 여러개를 사용하면 여러개를 묶을 수 있다.
sort를 어떻게 할지 반복문을 사용할지 고민하였는데 sort를 사용해서 pair된 묶음을 정렬할 수 있었다. 이건 인터넷 참고ㅠㅠ 효율적인 코드를 고민해봤는데 역시 sort를 사용할 수 있었다. 연월일 순서로 입력받아서 이른 날짜는 앞, 늦은 날짜는 뒤에 위치하여 날짜가 뒤로 위치하도록 하여 출력하였다!