-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1214.cpp
More file actions
48 lines (40 loc) · 892 Bytes
/
1214.cpp
File metadata and controls
48 lines (40 loc) · 892 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
/*************************************************************************
> File Name: 1214.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年03月01日 星期二 13时23分41秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
struct node
{
int a, b;
}l[10000];
bool cmp(node x, node y){ return x.b < y.b; }
int main()
{
int n;
cin>>n;
int count = 0;
int x, y;
for(int i = 0; i < n; i++)
{
cin>>x>>y;
if(x < y) l[i].a = x, l[i].b = y;
else l[i].a = y, l[i].b = x;
}
sort(l, l + n, cmp);
int res = 0, max = -10000;
for(int i = 0; i < n; i++)
{
if(l[i].a >= max)
{
res++;
max = l[i].b;
}
}
cout<<res;
return 0;
}