1.아이디어
이문제는 pair를 이용해 두개의 값을 저장한 후 sort을 이용해 정렬을 한다.
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
//vecotr v는 0으로 초기화된 pair 형태의 원소를 n개갖는다
vector <pair<int,int>> v(n);
//x를 second에 y를first에 저장 이유는 y가 우선적으로 정렬되야하기때문!
for(int i=0; i<n; i++)
{
cin>>v[i].second>>v[i].first;
}
sort(v.begin(),v.end());
for(int i=0; i<n; i++)
{
cout<<v[i].second<<' '<<v[i].first<<'\n';
}
}