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




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 <algorithm>
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int T,N,ret,tmp;
    pair<int,int> p[100000];
    
    cin >> T;
    
    for(int i = 0; i < T; i++){
        
        cin >> N;
        
        for(int j = 0; j < N; j++)
            cin >> p[j].first >> p[j].second;
        
        sort(p,p+N);
        
        ret = 1;
        tmp = p[0].second;
        for(int j = 1; j < N; j++){
            if(tmp > p[j].second){
                ret++;
                tmp = p[j].second;
            }
        }
            
        cout << ret << endl;
        
    }
    
}
cs


반응형

'프로그래밍 > 문제풀이' 카테고리의 다른 글

[etc] 백준 1436 영화감독 숌  (0) 2018.12.10
[etc] 백준 10809 알파벳 찾기  (0) 2018.12.10
[etc] 백준 1049 기타줄  (0) 2018.12.07
[etc] 백준 1931 회의실 배정  (0) 2018.12.07
[bfs] 백준 13460 구슬 탈출2  (0) 2018.11.28

+ Recent posts