POJ1083 Moving Tables(模拟)
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.
Input
The input consists of T test cases. The number of test cases ) (T is given in the first line of the input. 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 N+3-rd line, the remaining test cases are listed in the same manner as above.
Output
The output should contain the minimum time in minutes to complete the moving, one per line.
Sample Input
3
4
10 20
30 40
50 60
70 80
2
1 3
2 200
3
10 100
20 80
30 50
Output for the Sample Input
10
20
30
这道题,水题一道,就是求区间覆盖最大值,然后直接求出区间最大值*10就可以了。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std; int n,a[]; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
memset(a,,sizeof(a));
scanf("%d",&n);
for(int i=;i<n;i++)
{
int x,y;
scanf("%d%d",&x,&y);
if(x>y)swap(x,y);
if(x%==)x--;
if(y%==)y++;
for(int i=x;i<=y;i++)
a[i]++;
}
int maxx=-;
for(int i=;i<=;i++)
maxx=max(maxx,a[i]);
printf("%d\n",maxx*);
}
}
POJ1083 Moving Tables(模拟)的更多相关文章
- POJ1083 Moving Tables
POJ1083 Moving Tables Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35297 Accepted: ...
- POJ1083(Moving Tables)--简单模拟
题目链接:http://poj.org/problem?id=1083 如图所示在一条走廊的两侧各有200个房间,现在给定一些成对的房间相互交换桌子,但是走廊每次只能通过一组搬运, 也就是说如果两个搬 ...
- 解题报告:poj1083 Moving tables
2017-09-02 19:49:59 writer:pprp 题意说明: 比较简单的题,一开始被吓到了,后来才发现,其实可以用很简单的方法就可以解决: 就是在这样的房间中如果在i 和 j 中之后的1 ...
- Moving Tables(贪心或Dp POJ1083)
Moving Tables Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28304 Accepted: 9446 De ...
- zstu.2512. Moving Tables(贪心)
Moving Tables Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1182 Solved: 563 Description The famo ...
- 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 ...
- Moving Tables
Moving Tables Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- hdoj 1050 Moving Tables【贪心区间覆盖】
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
随机推荐
- jQuery框架Ajax常用选项
json(JavaScript Object Notation):轻量级的数据交换(交换的数据转换成与平台无关的)格式 java对象转换成json字符串:使用ObjectMapper类的writeVa ...
- Mysql分区表使用的一些限制和需要注意的地方
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt347 mysql分区策略都基于两个非常重要的假设:查询都能够过滤(prunn ...
- 【找不到与请求 URI匹配的 HTTP 资源】(转)
在.net下,创建一个HTTP服务,有很多方案,比较老ashx,一般处理程序(HttpHandler), Web Service SOAP协议的,数据格式是XML,HTTP协议 WCF ...
- 3.修改第一个程序来点亮LED
在上一节中已经将驱动程序框架搭建好了 接下来开始写硬件的操作(控制LED): (1)看原理图,确定引脚 (2)看2440手册 (3)写代码(需要使用ioremap()函数映射虚拟地址,在linux中只 ...
- SEO搜索引擎优化(一)
什么是SEO呢 英文为"Search Engine Optimization",中文名为"搜索引擎优化".SEO是指通过对网站进行站内优化和修复(网站Web结构 ...
- 为什么说汽车VIN码是汽车唯一的"身份证"
人有身份证,那么车有吗?当然了,汽车也是有"身份证"的,出厂时就会跟着车辆一起出生, 一般在车辆的挡风玻璃处.按照国际SAE国际规定,Vin码由17位字符组成,其中包含了车辆的生产 ...
- 想做iPhoneX抢购活动?压测大师先教你优化网站后台
北京时间9月13日凌晨1点,iPhone 10周年,在Apple Park乔布斯剧院,苹果发布了三款新iPhone.全面屏iPhone X来袭,这款被定义为未来的智能手机黑科技满满:全面屏,无线充电. ...
- AmpLab Tachyon and Shark update
一个开源的文件系统,拿来主义,先收藏,用得到细品. 简介:https://www.youtube.com/watch?v=cAZ624-69PQ 官网:http://tachyon-project.o ...
- IT之光
作为一个IT界的新新人才,现在拥有第一个博客,可以在这里学习和分享IT方面的知识和技术.
- Beta阶段冲刺日志集合贴
[Beta]Daily Scrum Meeting--Day1:http://www.cnblogs.com/RunningGuys/p/6890738.html [Beta]Daily Scrum ...