1. 문제
https://www.acmicpc.net/problem/10814
10814번: 나이순 정렬
온라인 저지에 가입한 사람들의 나이와 이름이 가입한 순서대로 주어진다. 이때, 회원들을 나이가 증가하는 순으로, 나이가 같으면 먼저 가입한 사람이 앞에 오는 순서로 정렬하는 프로그램을 작성하시오.
www.acmicpc.net
2. Note
구조체에 가입 순서를 포함하여 정렬해도 되지만, 안정 정렬(Stable sort)을 가능하게 하는 정렬 알고리즘을 사용하는 것이 좋다.
3. Reference
https://en.cppreference.com/w/cpp/algorithm/stable_sort
std::stable_sort - cppreference.com
template< class RandomIt > void stable_sort( RandomIt first, RandomIt last ); (1) template< class ExecutionPolicy, class RandomIt > void stable_sort( ExecutionPolicy&& policy, RandomIt first, RandomIt last ); (2) (since C++17) template< class RandomIt, cla
en.cppreference.com
https://www.geeksforgeeks.org/stable_sort-c-stl/
'Problem Solving' 카테고리의 다른 글
[BOJ11004] K번째 수 (K-th smallest) (0) | 2020.03.19 |
---|---|
[BOJ2749] 피보나치 수 3 (0) | 2020.03.16 |
[BOJ9663] N-Queen (0) | 2020.03.02 |
[BOJ10775] 공항 (0) | 2020.01.26 |
[BOJ2014] 소수의 곱 (0) | 2020.01.24 |