首页 > 代码库 > 找点(NYOJ891)

找点(NYOJ891)

//#define LOCAL
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
int const MAX_N=101;
typedef struct Point{
    int x,y;
    bool operator<(const Point &other) const
    {
        return x<other.x;
    };
};
Point Vec[MAX_N];
int N,R,x,y;
void solve()
{
    int coun=0,i;
    for(i=0;i<N;i++)
    {
        scanf("%d%d",&Vec[i].x,&Vec[i].y);
    }
    std::sort(Vec,Vec+N);
    int sum=Vec[0].y;
    coun=1;
    for(i=1;i<N;i++)
    {
        if(sum<Vec[i].x)
        {
                coun++;
                sum=Vec[i].y;
        }
        else
        {
            if(sum>Vec[i].y)
            {
                sum=Vec[i].y;
            }    
           }
    }
    printf("%d\n",coun);
}
int main()
{
#ifdef LOCAL
    freopen("891.in","r",stdin);
    freopen("891.out","w",stdout);
#endif
    while(~scanf("%d",&N))
    {
        solve();
    }
    return 0;
}