Short Cake
8PM - Animal Crossing Wild World

사생활 보호 설정

https://gamjia.tistory.com

Mini Rooms

  • 내 미니룸
  • 미니미설정
  • 미니룸설정
  • 답글수 [0]

What Friends Say

한마디로 표현해봐~

1촌평 관리

10814번 나이순 정렬

GamJia 2023. 4. 3. 09:13

단계별로 풀어보기 - 정렬 - 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