#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<tuple<int, int, string>> x;
for (int i = 0; i < n; i++)
{
int temp;
string temp2;
cin >> temp >> temp2;
x.push_back({ temp, i, temp2 });
}
sort(x.begin(), x.end());
for (int i = 0; i < n; i++)
{
cout << get<0>(x[i]) << " " << get<2>(x[i]) << "\n";
}
}
tuple을 사용하여 나이, 먼저들어온 순서, 이름순으로 정렬한다.
'Algorithm > Baekjoon' 카테고리의 다른 글
[C++] 백준 1568 새 (0) | 2021.02.04 |
---|---|
[C++] 백준 1543 문서 검색 (0) | 2021.02.04 |
[C++] 백준 1427 소트인사이드 (0) | 2021.02.03 |
[C++] 백준 1920 수 찾기 (0) | 2021.02.02 |
[C++] 백준 5397 키로거 (0) | 2021.02.02 |