http://poj.org/problem?id=1083

Description

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 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.

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

Sample Output

10
20
30
/**
poj 1083 思维
题目大意。如图所看到的在一条走廊的两側各有200个房间,如今给定一些成对的房间相互交换桌子,可是走廊每次仅仅能通过一组搬运。
也就是说假设两个搬运过程有交叉是不能同一时候搬运的,要依次来,一次搬运10min,问完毕全部的搬运的最少用时。
解题思路:考虑每一个房间有多少搬运过程须要经过,我们截取最大的房间经过的次数就能够了,挺锻炼思维的一道题。
*/
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std; int n,a[405]; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
memset(a,0,sizeof(a));
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int x,y;
scanf("%d%d",&x,&y);
if(x>y)swap(x,y);
if(x%2==0)x--;
if(y%2==1)y++;
for(int i=x;i<=y;i++)
a[i]++;
}
int maxx=-1;
for(int i=1;i<=400;i++)
{
maxx=max(maxx,a[i]);
}
printf("%d\n",maxx*10);
}
return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

poj1083 思考题的更多相关文章

  1. 复旦高等代数 I(16级)思考题

    思考题的说明 一.本学期高代I的思考题面向16级的同学,将不定期地进行更新; 二.欢迎16级的同学通过微信或书面方式提供解答图片或纸质文件给我,优秀的解答可以分享给大家: 三.请大家先独立解答思考题, ...

  2. 复旦高等代数 II(15级)思考题

    1.设 $f(x)=x^n+a_{n-1}x^{n-1}+\cdots+a_1x+a_0$ 是整系数首一多项式, 满足: $|a_0|$ 是素数且 $$|a_0|>1+\sum_{i=1}^{n ...

  3. Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]:思考题——谢勤政11061197

    第一题: 大楼里面的电梯一般分区域,或考虑思考题第四题的情况,运行楼层不一样的电梯属于不同的区域.然后在接口IRequest和IPassenger还有IElevator里面都加上int area这个属 ...

  4. 思考题:用Use Case获取需求的方法是否有什么缺陷,还有什么地方需要改进?(提示:是否对所有的应用领域都适用?使用的方便性?.......)

    思考题: 用Use Case获取需求的方法是否有什么缺陷,还有什么地方需要改进?(提示:是否对所有的应用领域都适用?使用的方便性?.......) 简答: 一.用例解释: 在软件工程中,用例是一种在开 ...

  5. 前端基本知识(三):JS的闭包理解(第一个思考题有错误,已修改)

    JS闭包的理解 一.变量的作用域 二.如何从外部读取局部变量 三.什么是闭包 四.深入理解闭包 五.闭包的用途 六.使用闭包注意情况 七.JavaScript的垃圾回收机制 八.一些思考题 一.变量作 ...

  6. POJ1083 Moving Tables

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

  7. 16 级高代 II 思考题十的多种证明

    16 级高代 II 思考题十  设 $V$ 是数域 $\mathbb{K}$ 上的 $n$ 维线性空间, $\varphi$ 是 $V$ 上的线性变换, 证明: $\varphi$ 的极小多项式 $m ...

  8. 16 级高代 II 思考题九的七种解法

    16 级高代 II 思考题九  设 $V$ 是数域 $\mathbb{K}$ 上的 $n$ 维线性空间, $\varphi$ 是 $V$ 上的线性变换, $f(\lambda),m(\lambda)$ ...

  9. 解题报告:poj1083 Moving tables

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

随机推荐

  1. Portal.MVC

    Portal.MVC Portal.MVC 简介 项目是基于MVC4+EF,带有角色,权限,用户中心及账户相关(登录,注册,修改密码,找回密码等)等基本功能.参考的开源项目nopcommerce,这是 ...

  2. 非常不错 Hadoop 的HDFS (Hadoop集群(第8期)_HDFS初探之旅)

    1.HDFS简介 HDFS(Hadoop Distributed File System)是Hadoop项目的核心子项目,是分布式计算中数据存储管理的基础,是基于流数据模式访问和处理超大文件的需求而开 ...

  3. JTree demo

    JFrame居中方法一:   setLocationRelativeTo(null); 注意:必须在整个frame初始化完成后再加上此语句,否则将显示在屏幕右下角 方法二: private Dimen ...

  4. CF 452A(Eevee-直接试)

    A. Eevee time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

  5. rac 中节点的vip在该节点启动不了,在其它节点正常启动。

    本实验是在虚拟机中! 与实验同样的问题:http://blog.csdn.net/wanghui5767260/article/details/38850335 问题描写叙述: 节点1.节点2和节点3 ...

  6. c++11多线程简介

    C++11开始支持多线程编程,之前多线程编程都需要系统的支持,在不同的系统下创建线程需要不同的API如pthread_create(),Createthread(),beginthread()等,使用 ...

  7. 《Qt on Android核心编程》夹

    china-pub在售前,售中环节退房,折扣低! 有朋友想看看<Qt on Android核心编程>的文件夹,So-- 文件夹     <Qt on Android核心编程>文 ...

  8. (五岁以下儿童)NS3样本演示:桥模块演示样品csma-bridge.cc凝视程序

    (五岁以下儿童)NS3:桥模块演示样品csma-bridge.cc凝视程序 1.Ns3 bridge模csma-bridge.cc演示示例程序的目光 // Network topology // // ...

  9. 【Linux探索之旅】第一部分第四课:磁盘分区,并完成Ubuntu安装

    内容简介 1.第一部分第四课:磁盘分区,并完成Ubuntu安装 2.第一部分第五课预告:Unity桌面,人生若只如初见 磁盘分区 上一课我们正式开始安装Ubuntu了,但是到了分区的那一步,小编却戛然 ...

  10. Java DOM4J读取XML

    DOM4J是dom4j.org出品的一个开源XML解析包.Dom4j是一个易用的.开源的库,用于XML,XPath和XSLT.它应用于Java平台,採用了Java集合框架并全然支持DOM,SAX和JA ...