728x90

 0. [c++] 백준


https://www.acmicpc.net/problem/10814


 1. 풀이


이번 문제에서는 처음 입력할 때 부터 이미 정렬된 상태로 입력이 되도록하여 문제를 해결하였다.



 2. 소스코드


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
 
using namespace std;
 
bool cmp(pair<intstring> a, pair<intstring> b) {
    return a.first < b.first;
}
 
vector<string> order[201];
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N;
    cin >> N;
 
    int old;
    string temp;
    for (int i = 0; i < N; i++) {
        cin >> old >> temp;
        order[old].push_back(temp);
    }
 
    for (int i = 1; i <= 200; i++) {
        for(int j=0;j<order[i].size();j++)
            cout << i << " " << order[i][j] << "\n";
    }
 
    return 0;
}
cs


 3. 참고




질문이나 지적 있으시면 댓글로 남겨주세요~

도움 되셨으면 하트 꾹!


+ Recent posts