어려운 문제는 아니지만


auto 를 처음 써봤다. 신기하군


C++ 11 버전부터 사용 가능한 기능이라네요.


나머지 코드는 그렇게 어렵지 않습니다.


vector와 sort()




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdio>
#include <algorithm>
#include <vector>
 
using namespace std;
 
int main(){
    int n, x, y;
    vector<pair<intint>> v;
    
    scanf("%d"&n);
    while(n--){
        scanf("%d %d"&x, &y);
        v.push_back(make_pair(x, y));
    }
    sort(v.begin(), v.end());
    
    for(auto lt : v){
        printf("%d %d\n", lt.first, lt.second);
    }
    
    return 0;
}
 
cs


+ Recent posts