vector와 pair클래스를 더욱 잘 알게 된 것 같다.
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef pair<int, string> pa;
bool compare(pa p1, pa p2) {
return p1.first < p2.first;
}
int main() {
pa p1;
vector<pa> arr;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> p1.first >> p1.second;
arr.push_back(p1);
}
stable_sort(arr.begin(), arr.end(),compare);
for (int i = 0; i < n; i++) {
cout << arr[i].first << ' ' << arr[i].second << '\n';
}
}