zoukankan      html  css  js  c++  java
  • 第一轮 L

    Scientific Conference
    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
    Submit Status
    
    Description
    Functioning of a scientific conference is usually divided into several simultaneous sections. For example, there may be a section on parallel computing, a section on visualization, a section on data compression, and so on.
    Obviously, simultaneous work of several sections is necessary in order to reduce the time for scientific program of the conference and to have more time for the banquet, tea-drinking, and informal discussions. However, it is possible that interesting reports are given simultaneously at different sections.
    A participant has written out the time-table of all the reports which are interesting for him. He asks you to determine the maximal number of reports he will be able to attend.
    
    Input
    The first line contains the number 1 ≤ N ≤ 100000 of interesting reports. Each of the next N lines contains two integers Ts and Te separated with a space (1 ≤ Ts < Te ≤ 30000). These numbers are the times a corresponding report starts and ends. Time is measured in minutes from the beginning of the conference.
    
    Output
    You should output the maximal number of reports which the participant can attend. The participant can attend no two reports simultaneously and any two reports he attends must be separated by at least one minute. For example, if a report ends at 15, the next report which can be attended must begin at 16 or later.
    
    Sample Input
    input	output
    
    5
    3 4
    1 5
    6 7
    4 5
    1 3
    
    	
    
    3
    经典题目~,不说了
    /*************************************************************************
    	> File Name: l.cpp
    	> Author:yuan 
    	> Mail: 
    	> Created Time: 2014年11月09日 星期日 23时09分29秒
     ************************************************************************/
    
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    #include<cmath>
    using namespace std;
    struct node
    {
        int s,e;
    };
    node t[100007];
    int n;
    bool cmp(node t1,node t2)
    {
        return t1.e<t2.e;
    }
    int main()
    {
        while(~scanf("%d",&n)){
            for(int i=0;i<n;i++)
            {
                scanf("%d%d",&t[i].s,&t[i].e);
            }
            int ans=0;
            sort(t,t+n,cmp);
            int k;
            for(int i=0;i<n;i++)
            {
                if(i==0) {ans++;k=t[0].e;continue;}
                else if(t[i].s-k>=1) {ans++;k=t[i].e;}
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
    


  • 相关阅读:
    MySQL问题记录——2003-Can't connect to MySQL server on 'localhost'(10038)
    MySQL学习——管理用户权限
    Java技巧——将前端的对象数组通过Json字符串传到后端并转换为对象集合
    JDK1.8新特性——使用新的方式遍历集合
    JDK1.8新特性——Collector接口和Collectors工具类
    Java技巧——比较两个日期相差的天数
    MySQL学习——操作自定义函数
    MySQL学习——操作存储过程
    MySQL问题记录——ERROR 1728 (HY000)
    Linux上安装nginx
  • 原文地址:https://www.cnblogs.com/codeyuan/p/4254396.html
Copyright © 2011-2022 走看看