您的位置:首页 > 其它

非洲小孩题意有点难懂

2015-03-10 22:12 232 查看

http://acm.nyist.net/JudgeOnline/problem.php?pid=1036

#include<iostream>

#include<cstdio>

#include<cmath>

#include<algorithm>

using namespace std;

struct time

{

 int b,e;

}t[105];

int cmp(struct time x,struct time y)

{

 return x.e<y.e;

}

int main()

{

 int n,i,count,end;

 int b1,b2,e1,e2;

 char c;

 while(~scanf("%d",&n))

 {

  for(i=0;i<n;i++)

  {

   scanf("%d%c%d%c%d%c%d",&b1,&c,&b2,&c,&e1,&c,&e2);

   t[i].b=b1*100+b2;

   t[i].e=e1*100+e2;

   if(t[i].b>t[i].e)

    swap(t[i].b,t[i].e);

  }

  sort(t,t+n,cmp);

  

  end=t[0].e;

  count=1;

  for(i=1;i<n;i++) //¶àÇø¼äÑ¡È¡×îÉÙ¹«¹²µã

  {

   if(t[i].b>end)

   {

    end=t[i].e;

    count++;

   }

  }

  printf("%d\n",count);

 }

 return 0;

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