您的位置:首页 > Web前端

ural 1203. Scientific Conference

2014-03-28 16:50 316 查看
http://acm.timus.ru/problem.aspx?space=1&num=1203

#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 400000
using namespace std;

struct node
{
int s,e;
bool operator <(const node &a)const
{
return ((e<a.e)||(e==a.e&&s>a.s));
}
}p[maxn];
int dp[maxn];

int main()
{
int n;
scanf("%d",&n);
for(int i=1; i<=n; i++)
{
scanf("%d%d",&p[i].s,&p[i].e);
}
sort(p+1,p+n+1);
int e=0,s=0;
int cnt=0;
for(int i=1; i<=n; i++)
{
if(p[i].s>=s)
{
s=p[i].e+1;
cnt++;
}
}
printf("%d\n",cnt);
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: