10814번 나이순 정렬
2023. 4. 3. 09:13ㆍBaekJoon
단계별로 풀어보기 - 정렬 - 9단계
https://www.acmicpc.net/problem/10814
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
bool compare(pair<int,string>a,pair<int,string>b)
{
return a.first<b.first;
}
int main()
{
int N;
cin>>N;
vector<pair<int,string>>temp(N);
for(int i=0;i<N;i++)
{
cin>>temp[i].first>>temp[i].second;
}
stable_sort(temp.begin(),temp.end(),compare);
for(int i=0;i<N;i++)
{
cout<<temp[i].first<<" "<<temp[i].second<<"\n";
}
return 0;
}
'BaekJoon' 카테고리의 다른 글
15649번 N과 M (1) (0) | 2023.04.03 |
---|---|
11870번 좌표 압축 (0) | 2023.04.03 |
1181번 단어 정렬 (0) | 2023.04.03 |
11651번 좌표 정렬하기 2 (0) | 2023.04.03 |
11650번 좌표 정렬하기 (0) | 2023.04.03 |