0
点赞
收藏
分享

微信扫一扫

HDOJ 2037 今年暑假不AC

仲秋花似锦 2022-08-23 阅读 68


​​http://acm.hdu.edu.cn/showproblem.php?pid=2037​​

#include <stdio.h>
#include <algorithm>
using namespace std;
typedef struct
{
int begin;
int end;
}Game;
Game aa[101];
bool cmp(Game a,Game b)
{
if(a.end<b.end)
return true;
else
return false;
}
int main()
{
int T;
while(scanf("%d",&T),T)
{
for(int i=0;i<T;i++)
scanf("%d%d",&aa[i].begin,&aa[i].end);
sort(aa,aa+T,cmp);
int max=1,temp=0;
for(int i=1;i<T;i++)
{
if(aa[temp].end<=aa[i].begin)
{
temp=i;
max++;
}
printf("%d\n",max);
}
return 0;
}

举报

相关推荐

0 条评论