ural 1203. Scientific Conference

http://acm.timus.ru/problem.aspx?space=1&num=1203

 1 #include <cstdio>

 2 #include <cstring>

 3 #include <algorithm>

 4 #define maxn 400000

 5 using namespace std;

 6 

 7 struct node

 8 {

 9     int s,e;

10     bool operator <(const node &a)const

11     {

12         return ((e<a.e)||(e==a.e&&s>a.s));

13     }

14 }p[maxn];

15 int dp[maxn];

16 

17 int main()

18 {

19     int n;

20     scanf("%d",&n);

21     for(int i=1; i<=n; i++)

22     {

23         scanf("%d%d",&p[i].s,&p[i].e);

24     }

25     sort(p+1,p+n+1);

26     int e=0,s=0;

27     int cnt=0;

28     for(int i=1; i<=n; i++)

29     {

30         if(p[i].s>=s)

31         {

32             s=p[i].e+1;

33             cnt++;

34         }

35     }

36     printf("%d\n",cnt);

37     return 0;

38 }
View Code

 

你可能感兴趣的:(conf)