zoukankan      html  css  js  c++  java
  • hdu2037

    View Code
    //找活动结束时间最小的,即以活动结束时间进行排序
    #include<iostream>
    #include
    <algorithm>
    using namespace std;
    int t ,k;
    struct node
    {
    int a,b;

    }s[
    101];

    int cmp( node x, node y )
    {
    if(x.b==y.b) return x.a<y.a;
    return x.b<y.b;
    }

    int main()
    {
    int i,j;
    while( cin>>t , t )
    {
    for( i = 0 ; i < t ; i++ )
    {
    cin
    >>s[i].a>>s[i].b;
    }

    sort( s , s
    +t , cmp );
    k
    =1;
    j
    =0;

    for(i=1;i<t;i++)
    {
    if(s[i].a>=s[j].b)
    {
    j
    =i;
    k
    ++;
    }
    }
    cout
    <<k<<endl;
    }
    return 0;
    }
  • 相关阅读:
    从进入这里,没有写过什么文章,现在开始吧
    24)
    23)
    22)
    21)
    20)
    19)
    18)
    17)
    16)
  • 原文地址:https://www.cnblogs.com/FCWORLD/p/2067192.html
Copyright © 2011-2022 走看看