Lecture Halls (会议安排)  

时间限制(普通/Java):1000MS/10000MS     运行内存限制:65536KByte
总提交: 38            测试通过: 20

描述

假设要在足够多的会场里安排一批活动,并希望使用尽可能少的会场。设计一个有效的算法进行安排。(这个问题实际上是著名的图着色问题。若将每一个活动作为图的一个顶点,不相容活动间用边相连。使相邻顶点着有不同颜色的最小着色数,相应于要找的最小会场数。)

编程任务: 对于给定的k个待安排的活动,编程计算使用最少会场的时间表。

输入

输入数据是由多组测试数据组成。每组测试数据输入的第一行有1 个正整数k,表示有k个待安排的活动。接下来的k行中,每行有2个正整数,分别表示k个待安排的活动开始时间和结束时间。时间以0 点开始的分钟计。

输出

对应每组输入,输出的每行是计算出的最少会场数。

样例输入

5
1 23
12 28
25 35
27 80
36 50

样例输出

3

题目上传者

crq

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 0x7fffffff;
const int maxn = 1000000;
int n;
int v[maxn]; int main()
{
int from, to, i, res;
while(scanf("%d", &n) != EOF) {
memset(v, 0, sizeof(v));
for(i = 0; i < n; i++) {
scanf("%d%d", &from, &to);
v[from] += 1;
v[to] += -1;
}
res = 0;
int maxv = -INF;
for(i = 0; i < maxn; i++) {
res += v[i];
if(res > maxv) {
maxv = res;
}
}
cout << maxv << endl;
}
return 0;
}

Lecture Halls的更多相关文章

  1. OJ题解记录计划

    容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001  A+B Problem First AC: 2 ...

  2. [C2P3] Andrew Ng - Machine Learning

    ##Advice for Applying Machine Learning Applying machine learning in practice is not always straightf ...

  3. Randy Pausch’s Last Lecture

          he University of Virginia American Studies Program 2002-2003.                     Randy Pausch ...

  4. note of introduction of Algorithms(Lecture 3 - Part1)

    Lecture 3(part 1) Divide and conquer 1. the general paradim of algrithm as bellow: 1. divide the pro ...

  5. codeforces 499B.Lecture 解题报告

    题目链接:http://codeforces.com/problemset/problem/499/B 题目意思:给出两种语言下 m 个单词表(word1, word2)的一一对应,以及 profes ...

  6. Nobel Lecture, December 12, 1929 Thermionic phenomena and the laws which govern them

    http://www.nobelprize.org/nobel_prizes/physics/laureates/1928/richardson-lecture.pdf OWEN W. RICHARD ...

  7. Jordan Lecture Note-1: Introduction

    Jordan Lecture Note-1: Introduction 第一部分要整理的是Jordan的讲义,这份讲义是我刚进实验室时我们老师给我的第一个任务,要求我把讲义上的知识扩充出去,然后每周都 ...

  8. Jordan Lecture Note-3: 梯度投影法

    Jordan Lecture Note-3:梯度投影法 在这一节,我们介绍如何用梯度投影法来解如下的优化问题: \begin{align} \mathop{\min}&\quad f(x)\n ...

  9. Jordan Lecture Note-2: Maximal Margin Classifier

    Maximal Margin Classifier Logistic Regression 与 SVM 思路的不同点:logistic regression强调所有点尽可能远离中间的那条分割线,而SV ...

随机推荐

  1. LINQ:使用Take和Skip实现分页

    随便找的,还没有试过代码. class Program { static int Main() { //每页大小 ; //页码 ; //源数据 string[] names = { "贤静& ...

  2. (转)ThinkPHP find方法 查询一条数据记录

    find() ThinkPHP find() 方法是和 select() 用法类似的一个方法,不同之处 find() 查询出来的始终只有一条数据,即系统自动加上了 LIMIT 1 限制. 当确认查询的 ...

  3. dom4j 笔记【转】

    SAXReader reader = new SAXReader(); Document doc = reader.read(...); List childNodes = doc.selectNod ...

  4. 如何修改UITableView每个cell的分隔线和左边的距离?

    在ios7中,UITableViewCell左侧会有默认15像素的空白.这时候,设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉.但是在ios8中,设置setSe ...

  5. CSS 布局Float 【4】

    一些浮动模型的基本知识:浮动模型也是一种可视化格式模型,浮动的框可以左右移动(根据float属性值而定),直到它的外边缘碰到包含框 或者另一个浮动元素的框的边缘.浮动元素不在文档的普通流中,文档的普通 ...

  6. js单条新闻向上滚动

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...

  7. display: -webkit-flex; 手机上图下文字,pad上有浮动。

    <article> <div class="boxt"> <div class="boxt-right"><img s ...

  8. python of zip moudle

    reprinted:http://www.cnblogs.com/beginman/archive/2013/03/14/2959447.html A. code talk is cheap ,sho ...

  9. QComboBox实现复选功能

    需求: 下拉列表有复选功能 不可编辑 显示所有选中项   关于QComboBox的复选功能有几种方案: QStandardItemModel + QStandardItem QListWidget + ...

  10. SQL Server 2008连接字符串写法大全(摘自网络)

    一..NET Framework Data Provider for SQL Server 类型:.NET Framework类库使用:System.Data.SqlClient.SqlConnect ...