NYOJ 91

 1 #include<iostream>
 2 #include<algorithm>
 3 #include<memory.h>
 4  using  namespace std;
 5  struct time{
 6      int bt,et;
 7      int t0;
 8 };
 9  struct time t[ 10001];
10 
11  bool cmp( struct time t1,  struct time t2)
12 {
13      return t1.bt < t2.bt || (t1.bt == t2.bt && t1.et < t2.et);
14 }
15 
16  int main()
17 {
18      int n,T,i,j,s,m;
19     cin>>T;
20      while(T--)
21     {
22         cin>>n;
23          for(i= 0; i<n; ++i)
24         {
25             cin>>t[i].bt>>t[i].et;
26             t[i].t0 =  1;
27         }
28         sort(t,t+n,cmp);
29         m =  0;
30          for(i= 1; i<n; ++i)
31         {
32              if(t[i].bt > t[i- 1].et) t[i].t0 += t[i- 1].t0;
33              else
34             {
35                  for(j=i- 1; j>= 0; --j)
36                      if(t[i].bt > t[j].et)
37                     {
38                         t[i].t0 += t[j].t0;
39                          break;
40                     }
41             }
42              if(t[i].t0 > m)
43                 m = t[i].t0;
44         }
45         cout<<m<<endl;
46     }
47      return  0;
48 }

转载于:https://www.cnblogs.com/yaling/archive/2013/04/26/3045831.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值