//https://www.acmicpc.net/problem/1931 #include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
#define lli long long int | |
int main() | |
{ | |
int n; | |
cin >> n; | |
vector<pair<lli, lli> > arr; | |
for(int i=0; i<n; i++){ | |
int a, b; | |
cin >> a >> b; | |
arr.push_back(pair<lli, lli>(b,a)); | |
} | |
sort(arr.begin(), arr.end()); | |
int cnt=1; | |
int end=arr[0].first; | |
for(int i=1; i<n; i++){ | |
if(end<=arr[i].second){ | |
end=arr[i].first; | |
cnt++; | |
} | |
} | |
cout << cnt << endl; | |
return 0; | |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180302_2600_구슬게임 (0) | 2018.03.02 |
---|---|
180302_9465_스티커 (0) | 2018.03.02 |
180301_1920_수 찾기 (0) | 2018.03.01 |
180228_10430_나머지 (0) | 2018.02.28 |
180227_1008_A/B (0) | 2018.02.27 |