반응형
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n=0;
cin >> n; //학생의 수 입력
vector<pair<pair<int, int>, pair<int, string>>>v(n); //첫번째 pair부터 연도,월,일,이름을 입력받을 벡터
for (int i = 0; i < n; i++)
{
cin >> v[i].second.second >> v[i].second.first >> v[i].first.second >> v[i].first.first; //미리선언한 벡터에 순서에 맞춰 입력
}
sort(v.begin(), v.end()); //오름차순으로 정렬
cout << v[n-1].second.second << '\n'; //가장작은값이 나이가 많은학생
cout << v[0].second.second <<'\n'; //가장큰값이 나이가 어린학생
return 0;
}
반응형
'Programming > Baekjoon' 카테고리의 다른 글
백준 2748 피보나치수2 [c++] (0) | 2022.01.15 |
---|---|
백준 1408 24 [c++] (0) | 2022.01.13 |
백준 11098 첼시를도와줘 [c++] (0) | 2022.01.13 |
백준 1977 완전제곱수 [c++] (0) | 2022.01.13 |
백준 2738 행렬덧셈 [c++] (0) | 2022.01.12 |