문제 링크입니다: https://www.acmicpc.net/problem/5635
5635번: 생일
문제 어떤 반에 있는 학생들의 생일이 주어졌을 때, 가장 나이가 어린 사람과 가장 많은 사람을 구하는 프로그램을 작성하시오. 입력 첫째 줄에 반에 있는 학생의 수 n이 주어진다. (1 ≤ n ≤ 100) 다음 n개 줄에는 각 학생의 이름과 생일이 "이름 dd mm yyyy"와 같은 형식으로 주어진다. 이름은 그 학생의 이름이며, 최대 15글자로 이루어져 있다. dd mm yyyy는 생일 일, 월, 연도이다. 이름이 같거나, 생일이 같은 사람은 없다. 출력
www.acmicpc.net
간단한 정렬 문제였습니다.
pair의 속성을 잘 생각해보면 되는 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int N; | |
cin >> N; | |
vector<pair<pair<int, int>, pair<int, string>>> v(N); | |
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" << v[0].second.second << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 2933번 미네랄 (0) | 2019.10.07 |
---|---|
백준 2186번 문자판 (7) | 2019.10.03 |
백준 6118번 숨바꼭질 (0) | 2019.09.29 |
백준 1516번 게임 개발 (0) | 2019.09.29 |
백준 1766번 문제집 (0) | 2019.09.29 |