Lecture Halls
Lecture Halls (会议安排)

总提交: 38 测试通过: 20
描述
假设要在足够多的会场里安排一批活动,并希望使用尽可能少的会场。设计一个有效的算法进行安排。(这个问题实际上是著名的图着色问题。若将每一个活动作为图的一个顶点,不相容活动间用边相连。使相邻顶点着有不同颜色的最小着色数,相应于要找的最小会场数。)
编程任务: 对于给定的k个待安排的活动,编程计算使用最少会场的时间表。
输入
输入数据是由多组测试数据组成。每组测试数据输入的第一行有1 个正整数k,表示有k个待安排的活动。接下来的k行中,每行有2个正整数,分别表示k个待安排的活动开始时间和结束时间。时间以0 点开始的分钟计。
输出
对应每组输入,输出的每行是计算出的最少会场数。
样例输入
5
1 23
12 28
25 35
27 80
36 50
样例输出
3
题目上传者
#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的更多相关文章
- OJ题解记录计划
容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001 A+B Problem First AC: 2 ...
- [C2P3] Andrew Ng - Machine Learning
##Advice for Applying Machine Learning Applying machine learning in practice is not always straightf ...
- Randy Pausch’s Last Lecture
he University of Virginia American Studies Program 2002-2003. Randy Pausch ...
- 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 ...
- codeforces 499B.Lecture 解题报告
题目链接:http://codeforces.com/problemset/problem/499/B 题目意思:给出两种语言下 m 个单词表(word1, word2)的一一对应,以及 profes ...
- 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 ...
- Jordan Lecture Note-1: Introduction
Jordan Lecture Note-1: Introduction 第一部分要整理的是Jordan的讲义,这份讲义是我刚进实验室时我们老师给我的第一个任务,要求我把讲义上的知识扩充出去,然后每周都 ...
- Jordan Lecture Note-3: 梯度投影法
Jordan Lecture Note-3:梯度投影法 在这一节,我们介绍如何用梯度投影法来解如下的优化问题: \begin{align} \mathop{\min}&\quad f(x)\n ...
- Jordan Lecture Note-2: Maximal Margin Classifier
Maximal Margin Classifier Logistic Regression 与 SVM 思路的不同点:logistic regression强调所有点尽可能远离中间的那条分割线,而SV ...
随机推荐
- 关于timestamp的二三事
之所以要写timestamp的随笔,是因为之前对它的理解存在误区,so. I have to remind myself by writing this informal essay. 微软文档链接: ...
- 带计时器的做题器(gui
新学 1 JCheckBox chckbxA = new JCheckBox("a"); JCheckBox的监听器接口ItemListener,响应方法itemStateChan ...
- linux变量心得
前一段时间学习了一下linux的变量,现在总结有3点需要特别注意: linux变量和C/C++变量的区别 linux变量的引用 linux变量特有的命令替换 先说第一点,linux变量更像是宏定义,只 ...
- jQuery 图片轮播
HTML <div class="carousel"> <ul class="car-img"> <li> ...
- ThinkPHP 使用极光推送给ios推送消息
HTML <div id="wrap"><a href="<{:U('Push/pushData')}>">推送</a ...
- js监控键盘大小写事件
JavaScript键盘事件侦听 在使用JavaScript做WEB键盘事件侦听捕获时,主要采用onkeypress.onkeydown.onkeyup三个事件进行出来.该三个事 件的执行顺序如 ...
- winform 绘制label 中文字 - 摘
private void label2_Paint(object sender, PaintEventArgs e) {//绘制label中文字 string text = "Sri Lan ...
- Tr A
Problem Description A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973. Input 数据的第一行是一个T,表示有T组数据. 每组数据的第 ...
- spring mvc标准项目结构
src com.xxx.inews.dao com.xxx.inews.dao.impl com.xxx.inews.data.entity com.xxx.inews.data.vo com.xxx ...
- SPSS方差分析
1.overall:一切的,全面地 单因素方差分析:分析--比较均值--单因素ANOVA.多因素方差分析:分析--一般线性模型--单变量. 单因素方差分析和单变量方差分析区别:单因素针对的是自变量(自 ...