Scientific Conference

Scientific Conference

Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Submit Status Practice URAL 1203

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 Teseparated 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

贪心:

    结束的越早越是优;

#include<cstdio>
#include<cstring>
#include<algorithm>
const int maxn = 1e5+5;
using namespace std;
struct node{
    int s, t;
    bool operator < (const node &x)const{
        return t < x.t;
    }
}a[maxn];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d%d", &a[i].s, &a[i].t);
    }
    sort(a, a+n);
    int ans = 0;
    int tmp = 0;
    for(int i = 0; i < n; i++){
        if(a[i].s > tmp){
            tmp = a[i].t;
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}
时间: 2024-10-18 09:32:21

Scientific Conference的相关文章

URAL1203——DPor贪心——Scientific Conference

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, simu

URAL 1203 Scientific Conference(贪心 || DP)

Scientific Conference 之前一直在刷计算几何,邀请赛连计算几何的毛都买见着,暑假这一段时间就做多校,补多校的题目,刷一下一直薄弱的DP.多校如果有计算几何一定要干掉-.- 题意:给你N个报告会的开始时间跟结束时间,问你做多可以听几场报告会.要求报告会之间至少间隔为1. 思路:其实是个活动安排问题,可以用贪心也可以用DP,贪心写起来会比较简单一些,因为练习DP,所以又用DP写了一遍. 贪心的话就是一个很简单的活动选择问题,从结束时间入手,找每次的最优选择. 1 struct n

[贪心][DP][Ural 1203]Scientific Conference

1203. Scientific Conference Time limit: 1.0 secondMemory limit: 64 MB 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,

URAL 1203 Scientific Conference 简单dp 难度:0

http://acm.timus.ru/problem.aspx?space=1&num=1203 按照结束时间为主,开始时间为辅排序,那么对于任意结束时间t,在此之前结束的任务都已经被处理,从这个时间开始的任务都正要被处理, 因为t<=3e5,可以用简单dp解决 #include <cstdio> #include <algorithm> using namespace std; const int maxn=1e5+5; int n; typedef pair&l

第一轮 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

Draft-TCAD

IEEEtran.cls 1 %% 2 %% IEEEtran.cls 2007/03/05 version V1.7a 3 %% 4 %% 5 %% This is the official IEEE LaTeX class for authors of the Institute of 6 %% Electrical and Electronics Engineers (IEEE) Transactions journals and 7 %% conferences. 8 %% 9 %% S

ENode框架Conference案例分析系列之 - 事件溯源如何处理重构问题

前言 本文可能对大多数不太了解ENode的朋友来说,理解起来比较费劲,这篇文章主要讲思路,而不是一上来就讲结果.我写文章,总是希望能把自己的思考过程尽量能表达出来,能让大家知道每一个设计背后的思考的东西.我觉得,任何设计的结果可能看起来很高大上,一张图即可,但背后的思考,才是更有价值的东西. 本篇文章想写一下ENode如何处理由于业务需求的变化而导致的模型重构的问题.DDD之所以能解决复杂的业务问题是因为DDD是一种模型驱动的软件设计方法.用领域模型来捕获业务需求,根据业务需求,抽象出满足需求的

ENode框架Conference案例分析系列之 - 架构设计

Conference架构概述 先贴一下Conference案例的在线地址,UI因为完全拿了微软的实现,所以都是英文的,以后我有空再改为中文的. Conference后台会议管理:http://www.enode.me/conference Conference前台预定座位:http://www.enode.me/registration ENode论坛开源案例:http://www.enode.me/post ENode开源项目地址:https://github.com/tangxuehua/e

ENode框架Conference案例分析系列之 - ENode框架初始化

前言 Conference案例是使用ENode框架来开发的.之前我没有介绍过ENode框架是如何启动的,以及启动时要注意的一些点,估计很多人对ENode框架的初始化这一块感觉很复杂,一头雾水.所以,本文想简单介绍一下在做一个实际项目时,我们该如何初始化ENode. 使用ENode开发的项目的顶层宿主工程一般有两类:1)前台Web项目,它的职责就是发送命令:2)后台ProcessorHost项目,负责处理命令或事件: 这两类项目的初始化方式完全一样,只是Web项目可能需要多初始化Controlle