HDU 2037 今年暑假不AC

来源:互联网 发布:淘宝达人管理中心地址 编辑:程序博客网 时间:2024/06/03 16:33
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define N 105struct node{    int s,e;}t[N];int cmp(node p,node q){    if(p.e==q.e)    {        return p.s<q.s;    }    else    {        return p.e<q.e;    }}int main(){    int n;    while(scanf("%d",&n)!=EOF&&n)    {        int i,j;        for(i=0;i<n;i++)        {            scanf("%d%d",&t[i].s,&t[i].e);        }        sort(t,t+n,cmp);//按结束时间排序        int sum=0;        for(i=0;i<n;)        {            for(j=i+1;j<n;j++)            {                if(t[j].s>=t[i].e)                {                    sum++;                    break;                }            }            i=j;        }        printf("%d\n",sum+1);    }    return 0;}

0 0
原创粉丝点击