-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1214_t.cpp
More file actions
53 lines (47 loc) · 965 Bytes
/
Copy path1214_t.cpp
File metadata and controls
53 lines (47 loc) · 965 Bytes
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*************************************************************************
> File Name: 1214_t.cpp
> Author: dulun
> Mail: dulun@xiyoulinux.org
> Created Time: 2016年03月17日 星期四 20时06分07秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;
const int N = 50086;
struct Node
{
int l, r;
};
Node a[N];
bool cmp(Node a, Node b)
{
return a.r < b.r;
}
int main()
{
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%d%d", &a[i].r, &a[i].l);
if(a[i].l > a[i].r)
swap(a[i].l, a[i].r);
}
sort(a, a+n, cmp);
int ans = 1;
int cnt = a[0].r;
for(int i = 1; i < n; i++)
{
if(a[i].l >= cnt)
{
cnt = a[i].r;
++ans;
}
}
cout<<ans<<endl;
return 0;
}