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
题目上传者
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;
}
转载于:https://www.cnblogs.com/pangblog/p/3262967.html
Lecture Halls相关推荐
- futuretask java 并发请求_Java面试题整理一(侧重多线程并发)
1..是否可以在static环境中访问非static变量? 答:static变量在Java中是属于类的,它在所有的实例中的值是一样的.当类被Java虚拟机载入的时候,会对static变量进行初始化.如 ...
- Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.2. The Python language
Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.2. The Python language 1.2.2. 基本 ...
- 3P5 Industrial Engineering Lecture 1-2: Method of Study
3P5 Industrial Engineering Lecture 1-2: Method of Study 文章目录 3P5 Industrial Engineering Lecture 1-2: ...
- lecture 3 qkine- start with connections
lecture 3 qkine start with connections keep an eye on the smart ones for you to recruit in the futur ...
- Colorful Lecture Note(栈的模拟)
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi is writing an algorithm lecture note for Little Ho. ...
- hihocoder #1103 : Colorful Lecture Note微软苏州校招笔试 1月10日(字符串处理+栈)
#1103 : Colorful Lecture Note 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi is writing an algorit ...
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 12—Support Vector Machines 支持向量机...
Lecture 12 支持向量机 Support Vector Machines 12.1 优化目标 Optimization Objective 支持向量机(Support Vector Machi ...
- Introduction to Cryto Crptocurrencies Lecture 1
Lecture 1.2 Hash Pointer & Data Structure Use Case 1. 什么是Block Chain呢? 想象一个像链表一样的结构,只不过与通常的指向下一块 ...
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 16—Recommender Systems 推荐系统...
Lecture 16 Recommender Systems 推荐系统 16.1 问题形式化 Problem Formulation 在机器学习领域,对于一些问题存在一些算法, 能试图自动地替你学习到 ...
最新文章
- 在 Windows 上像 Linux 一样使用命令
- 站着说话不腰疼!这种技术水平,你能做到?
- ExtJs Grid 合计 [Ext | GridPanel | GridSummary]
- 平衡二叉树AVL插入
- linux系统nginx启动不了,nginx启动不了,求大神帮助!
- 天地图卫星地图_AutoCAD使用卫星地图
- Flask自定义时间过滤器
- android sharedpre,android 数据存储一SharedPrenference存储简单数据
- 无锁atomicInteger
- 标注工具——yarn的学习笔记
- LeetCode 230. 二叉搜索树中第K小的元素(递归)
- 雷达人体存在感应器方案,智能物联网感知技术,实时感应人体存在
- 利用哈夫曼编码英文字母表
- [RTOS]uCOS、FreeRTOS、RTThread、RTX等RTOS的对比之特点
- 微信公众号跳转小程序,详细教程
- Python 合并两个或多个pdf文件(获取pdf文件指定页)
- 三、Allan方差分析
- Python案例1—人民币与美元的汇率兑换V_8.0
- 机器学习——概念理解之IoU
- 树莓派mjpg-streamer实现监控功能