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 }
  • 相关阅读:
    tiptop之4gl调试3/31
    打印空白3/31
    佛陀教育入门
    什么是佛教
    智、觉
    保持头脑清醒的窍门2/13
    php中将数组转换为指定符号分割的字符串
    kali下apche配置多网站
    php数组指定字段排序
    php 语句块耗时性能测试
  • 原文地址:https://www.cnblogs.com/yaling/p/3045831.html
Copyright © 2011-2022 走看看