zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    Html5新标签解释及用法
    时间线效果
    NHibernate数据访问层核心代码
    C#开源资源项目
    安卓开发环境搭建之最新版(So Easy!)
    WIN8相关资源汇总
    HTML5 Shiv – 让该死的IE系列支持HTML5吧
    WCF 提高传输数据性能方法之二 (数据分割)
    支付宝集成问题(.net篇)
    WCF 提高传输数据性能方法之一 (使用压缩)
  • 原文地址:https://www.cnblogs.com/yaling/p/3045831.html
Copyright © 2011-2022 走看看