poj1083 思考题
http://poj.org/problem?id=1083
Description

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
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
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 思考题的更多相关文章
- 复旦高等代数 I(16级)思考题
思考题的说明 一.本学期高代I的思考题面向16级的同学,将不定期地进行更新; 二.欢迎16级的同学通过微信或书面方式提供解答图片或纸质文件给我,优秀的解答可以分享给大家: 三.请大家先独立解答思考题, ...
- 复旦高等代数 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 ...
- Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]:思考题——谢勤政11061197
第一题: 大楼里面的电梯一般分区域,或考虑思考题第四题的情况,运行楼层不一样的电梯属于不同的区域.然后在接口IRequest和IPassenger还有IElevator里面都加上int area这个属 ...
- 思考题:用Use Case获取需求的方法是否有什么缺陷,还有什么地方需要改进?(提示:是否对所有的应用领域都适用?使用的方便性?.......)
思考题: 用Use Case获取需求的方法是否有什么缺陷,还有什么地方需要改进?(提示:是否对所有的应用领域都适用?使用的方便性?.......) 简答: 一.用例解释: 在软件工程中,用例是一种在开 ...
- 前端基本知识(三):JS的闭包理解(第一个思考题有错误,已修改)
JS闭包的理解 一.变量的作用域 二.如何从外部读取局部变量 三.什么是闭包 四.深入理解闭包 五.闭包的用途 六.使用闭包注意情况 七.JavaScript的垃圾回收机制 八.一些思考题 一.变量作 ...
- POJ1083 Moving Tables
POJ1083 Moving Tables Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35297 Accepted: ...
- 16 级高代 II 思考题十的多种证明
16 级高代 II 思考题十 设 $V$ 是数域 $\mathbb{K}$ 上的 $n$ 维线性空间, $\varphi$ 是 $V$ 上的线性变换, 证明: $\varphi$ 的极小多项式 $m ...
- 16 级高代 II 思考题九的七种解法
16 级高代 II 思考题九 设 $V$ 是数域 $\mathbb{K}$ 上的 $n$ 维线性空间, $\varphi$ 是 $V$ 上的线性变换, $f(\lambda),m(\lambda)$ ...
- 解题报告:poj1083 Moving tables
2017-09-02 19:49:59 writer:pprp 题意说明: 比较简单的题,一开始被吓到了,后来才发现,其实可以用很简单的方法就可以解决: 就是在这样的房间中如果在i 和 j 中之后的1 ...
随机推荐
- JDBC批处理executeBatch
JDBC运行SQL声明,有两个处理接口,一PreparedStatement,Statement,一般程序JDBC有多少仍然比较PreparedStatement 只要运行批处理,PreparedSt ...
- 悼念传奇,约翰询问·纳什和他的妻子艾丽西亚致敬,创建一个传奇,爱数学
约翰·阅读·纳什的传记.我渴望录制通道 我一直相信数字,无论逻辑方程使我们认为.但这种追求一生的后,我问自己:"这是什么逻辑?谁决定的理由?"我的探索让我从物理到形而上,最后到了妄 ...
- Google Maps Android API v2 (3)- 地图添加到Android应用程序
添加地图的基本步骤是: (一旦)按照以下步骤[入门] [开始],获得API,获取密钥所需的属性,并添加到您的Android清单. 添加一个碎片对象 要处理地图的活动.做到这一点最简单的方法是增加一个 ...
- Windows Phone 8 - Runtime Location API - 2
原文:Windows Phone 8 - Runtime Location API - 2 在<Windows Phone 8 - Runtime Location API - 1>介绍基 ...
- gradle下载(转)
http://services.gradle.org/distributions services.gradle.org/ distributions/ gradle-2.2.1-rc-1-all.z ...
- Android使用的开发MediaRecorder录制声音
至 Android 录制声音的应用,Android提供 MediaRecorder 类别.大约MediaRecorder可以参考一个特定的解释<Android开发之MediaRecorder类具 ...
- DOM操作应用
创建元素 document.createElement("li"); 添加节点 oUl.appendChild(oLi); 在某个元素之前插入一个节点 oUl.insertBefo ...
- Java正则表达式例子汇总
1.过滤特殊字符 package com.sheepmu.text; /* * @author sheepmu */ public class HWCompetition { public stati ...
- css--左右visibility建立 “collapse”值问题
1.您可能已使用visibility一千次,最常用的是visible和hidden.它用来显示或隐藏元素. 有第三很少已使用的值它是collapse,在表格的行,列中使用有差异外,他和hidden的作 ...
- hdu3844 Mining Your Own Business,无向双连接组件
点击打开链接 无向图的双连通分量 #include<cstdio> #include<stack> #include<vector> #include<map ...