OpenJudge/Poj 1083 Moving Tables
1.链接地址:
http://poj.org/problem?id=1083
http://bailian.openjudge.cn/practice/1083/
2.题目:
- 总时间限制:
 - 1000ms
 - 内存限制:
 - 65536kB
 
- 描述
 - The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.
 
The
floor has 200 rooms each on the north side and south side
along the corridor. Recently the Company made a plan to reform its
system. The reform includes moving a lot of tables between rooms.
Because the corridor is narrow and all the tables are big, only one
table can pass through the corridor. Some plan is needed to make the
moving efficient. The manager figured out the following plan: Moving a
table from a room to another room can be done within 10 minutes.
When moving a table from room i to room j, the part of the
corridor between the front of room i and the front of room j
is used. So, during each 10 minutes, several moving between two
rooms not sharing the same part of the corridor will be done
simultaneously. To make it clear the manager illustrated the possible
cases and impossible cases of simultaneous moving.
For
each room, at most one table will be either moved in or moved out. Now,
the manager seeks out a method to minimize the time to move all the
tables. Your job is to write a program to solve the manager's problem.- 输入
 - The input consists of T test cases. The number of test cases )
 
(T is given in the first line of the input file. Each test case begins
with a line containing an integer N , 1 <= N <= 200, that
represents the number of tables to move.
Each of the following N
lines contains two positive integers s and t, representing that a table
is to move from room number s to room number t each room number appears
at most once in the N lines). From the 3 + N -rd
line, the remaining test cases are listed in the same manner as above.- 输出
 - The output should contain the minimum time in minutes to complete the moving, one per line.
 - 样例输入
  3
4
10 20
30 40
50 60
70 80
2
1 3
2 200
3
10 100
20 80
30 50- 样例输出
  10
20
30- 来源
 - Taejon 2001
 
3.思路:
4.代码:
#include "stdio.h"
//#include "stdlib.h"
#define NUM 200
int aa[NUM];
int main()
{
int t,n;
int i,j,k;
int a,b;
int tmp;
int max;
scanf("%d",&t);
for(i=;i<t;i++)
{
for(j=;j<NUM;j++) aa[j]=;
scanf("%d",&n);
for(j=;j<n;j++)
{
scanf("%d%d",&a,&b);
if(a>b){tmp=a;a=b;b=tmp;}
for(k=(a-)/;k<=(b-)/;k++) aa[k]++;
}
max=-;
for(int j=;j<NUM;j++){if(aa[j]>max)max=aa[j];}
printf("%d\n",max*); }
//system("pause");
return ;
}
OpenJudge/Poj 1083 Moving Tables的更多相关文章
- POJ 1083 Moving Tables 思路 难度:0
		
http://poj.org/problem?id=1083 这道题题意是有若干段线段,每次要求线段不重叠地取,问最少取多少次. 因为这些线段都是必须取的,所以需要让空隙最小 思路: 循环直到线段全部 ...
 - POJ 1083  Moving Tables
		
题意:一个建筑物里有400个房间,房间都在一层里,在一个走廊的两侧,如图,现在要搬n张桌子,告诉你每张桌子是从哪个屋搬到哪个屋,搬桌子的线路之间不可以有重叠,问最少搬几次. 解法:贪心.一开始觉得只要 ...
 - 1083 Moving Tables
		
题目链接:http://poj.org/problem?id=1083 题意: 走廊两边分别有200个房间,一边连续编号为1-399的奇数,另一边是2-400的偶数, 如果从房间 i 移动桌子到房间 ...
 - poj 1083 Moving Tables_dp
		
题意:给你n个凳子,接着告诉你一个凳子从a房间到b房间,运输时间为10分钟,走廊很窄能通过一张凳子,当然不堵塞的话能同时扮凳子,问最小花费多少时间 因为数据很小就直接用数组统计了,a,b如果是奇数的话 ...
 - POJ 1083 && HDU 1050 Moving Tables (贪心)
		
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
 - zstu.2512. Moving Tables(贪心)
		
Moving Tables Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1182 Solved: 563 Description The famo ...
 - Moving Tables(贪心或Dp POJ1083)
		
Moving Tables Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28304 Accepted: 9446 De ...
 - HDOJ 1050 Moving Tables
		
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
 - 1050 Moving Tables
		
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
 
随机推荐
- 教你50招提升ASP.NET性能(九):显式的使用using语句减少内存泄露
			
(15)Reduce memory leaks dramatically with the “using” statement 招数15: 显式的使用using语句减少内存泄露 If a type i ...
 - ILSpy反编译工具的使用
			
以前一直使用reflector来查看.net类库的一些信息,不过,自2011年2月份开始,reflector就开始转向收费软件了,所以爱好免费软件的开发者们转而开发自己的反编译软件.于是ILspy就因 ...
 - SQLyog破解版:SQLyog MySQL GUI 11.2.4-0 Ultimate中文版 带序列号【转载】
			
SQLyog 是一个易于使用的.快速而简洁的图形化管理MYSQL数据库的工具,目前(2013年9月11日)最新版为:SQLyog Ultimate – MySQL GUI v11.24,本站已亲测比较 ...
 - hdu 5480 Conturbatio 线段树 单点更新,区间查询最小值
			
Conturbatio Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=54 ...
 - ios开发——实用技术篇Swift&Swift调用C、C++、Object
			
Swift调用C.C++.Object 1.Swift调用C语言a,首先在项目中添加 CFile 文件命名为CHello,同时产生桥梁文件. b,创建之后的项目结构 b,在CHello.h文件中编写接 ...
 - node.js 浏览器中输出 “hello world”
			
前段时间花了几个小时,在command面板输出了“hello world”,今天就来说说怎么在浏览器上输入一个地址,然后页面输出“hello world”. 首先要搭建一个基础的 HTTP 服务器 一 ...
 - C#_数据库基本交互
			
//app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> ...
 - Eclipse 各种包说明
			
2001年11月7日 ,Eclipse 1.0发布 半年之后,2002年6月27日Eclipse进入了2.0时代.2.0时代的Eclipse经历了2.0和2.1两个大的版本.其中2.0在 之后又推出了 ...
 - Android(java)学习笔记124:Android权限大全
			
访问登记属性 android.permission.ACCESS_CHECKIN_PROPERTIES读取或写入登记check-in数据库属性表的权限 获取错略位置 android.permissio ...
 - js用斜率判断鼠标进入div的四个方向
			
网上大部分判断鼠标移入div移入移出都是使用一下方法: 这个方法确实十分奇特,使用起来十分方便. 后来自己看了一些文章,看到有另一种以斜率的方法来判断鼠标的移动方向. 上图是此方法的示意图,以浏览器左 ...
 
			
		
