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 



10 20 
30 40 
50 60 
70 80 

1 3 
2 200 

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(模拟)的更多相关文章

  1. POJ1083 Moving Tables

    POJ1083 Moving Tables Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 35297   Accepted: ...

  2. POJ1083(Moving Tables)--简单模拟

    题目链接:http://poj.org/problem?id=1083 如图所示在一条走廊的两侧各有200个房间,现在给定一些成对的房间相互交换桌子,但是走廊每次只能通过一组搬运, 也就是说如果两个搬 ...

  3. 解题报告:poj1083 Moving tables

    2017-09-02 19:49:59 writer:pprp 题意说明: 比较简单的题,一开始被吓到了,后来才发现,其实可以用很简单的方法就可以解决: 就是在这样的房间中如果在i 和 j 中之后的1 ...

  4. Moving Tables(贪心或Dp POJ1083)

    Moving Tables Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28304   Accepted: 9446 De ...

  5. zstu.2512. Moving Tables(贪心)

     Moving Tables Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 1182  Solved: 563 Description The famo ...

  6. HDOJ 1050 Moving Tables

    Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  7. 1050 Moving Tables

    Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  8. Moving Tables

    Moving Tables Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total ...

  9. hdoj 1050 Moving Tables【贪心区间覆盖】

    Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

随机推荐

  1. Mybatis --- 创建方法、全局配置

    总体介绍:MyBatis实际上是Ibatis3.0版本以后的持久化层框架[也就是和数据库打交道的框架]!     和数据库打交道的技术有:      原生的JDBC技术--->Spring的Jd ...

  2. instanceof 是如何工作的

    知其然 JavaScript 提供 instanceof 关键字判断一个对象所属的构造函数.在 js 高级编程中讲到 instanceof 的作用: instanceof 操作符,用来测试实例与原型链 ...

  3. Android检查更新下载安装

    检查更新是任何app都会用到功能,任何一个app都不可能第一个版本就能把所有的需求都能实现,通过不断的挖掘需求迭代才能使app变的越来越好.检查更新自动下载安装分以下几个步骤: 请求服务器判断是否有最 ...

  4. 哪有Python视频百度云链接?

    说到Python视频哪个好,小编在这里不好下结论.毕竟孰好孰坏,只有合适的才是最好的.就像买鞋子,一双鞋子好不好,只有合脚才是真的好.不过,这里有些个人认为通俗易懂的Python视频可以分享给大家. ...

  5. Jmeter+Jenkins的聚合报告中添加QPS栏目显示

    1.进入jmeter/extras目录,修改 jmeter-results-detail-report_21.xsl   2.打开文件修改 如上所示,在文件中添加6个地方关于QPS的显示即可, 然后替 ...

  6. Phpstorm中使用SFTP

    Phpstorm中经常会出现FTP连接失败的问题,这个时候我们可以使用SFTP来连接服务器. 1.添加服务器.tools--deployment--configuration/browse Remot ...

  7. Java GC 日志详解

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt105 java GC日志可以通过 +PrintGCDetails开启 以Pa ...

  8. 【Java IO流】字节流和字符流详解

    字节流和字符流 对于文件必然有读和写的操作,读和写就对应了输入和输出流,流又分成字节和字符流. 1.从对文件的操作来讲,有读和写的操作——也就是输入和输出. 2.从流的流向来讲,有输入和输出之分. 3 ...

  9. java课设

    1.代码截图: 2.设计思路 建立GUI界面,系统产生一个随机数(对用户不可见),然后用户输入猜测数,系统根据用户每次输入的数据给出评语(偏大,偏小,猜测成功).当用户最终猜测成功后,就把当次的随机数 ...

  10. Jquery基础添加删除内容

    直入主题,工作中比较常用的功能在input框内添加内容,不白话了,上代码! 布局: <div id="content"> <input type="te ...