poj1083
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 一道思维题,主要思路是不要拘泥于路径和搬运的顺序(我一开始就是过分关于与顺序,打算用map映射来一步一步的做,发现太过麻烦吐血放弃!)。思考后,其实可以用一个vectoe或者array把每一次路过的地方记录并加起来。
坑:注意40>>30 30>>40这两种方向也是要考虑的。
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
for (int i = ; i < n; ++i)
{
int k;
cin>>k;
vector<int> v(,);
for (int j= ; j < k; ++j)
{
int a,b,t;
cin>>a>>b;
if(a>b) {t=a;a=b;b=t;}
for(int l=(a-)/;l<=(b-)/;l++)
{
v[l]++;
}
}
sort(v.begin(),v.end());
cout<<v[]*<<endl;
}
return ;
}
poj1083的更多相关文章
- POJ1083 Moving Tables
POJ1083 Moving Tables Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35297 Accepted: ...
- 解题报告: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 ...
- poj1083 贪心
K - 简单dp Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:10000KB 64bit ...
- poj1083 思考题
http://poj.org/problem?id=1083 Description The famous ACM (Advanced Computer Maker) Company has rent ...
- poj1083,基本互斥问题
题意:南北两侧各有200个房间,两侧房间之间有一个走廊 现在需要把桌子从这400个房间之中搬进搬出,每一张桌子需要10分钟时间,如果走廊因为有桌子搬运而占用,则需等待,求共需多少时间(分钟)将桌子搬完 ...
- POJ1083 Moving Tables(模拟)
The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in ...
- 【POJ1083】 Moving Tables (并行的搬运)
BUPT2017 wintertraining(15) #6E 题意 房间1和2,3和4,...,399和400共用一节走廊,有q次从房间li到ri的搬运桌子,一次搬运10分钟.两个搬运如果走廊有重叠 ...
- POJ1083(Moving Tables)--简单模拟
题目链接:http://poj.org/problem?id=1083 如图所示在一条走廊的两侧各有200个房间,现在给定一些成对的房间相互交换桌子,但是走廊每次只能通过一组搬运, 也就是说如果两个搬 ...
随机推荐
- 给div设置background-color: rgba(0, 0, 0, 0.2)属性,并加了css3动画--opacity动画淡出动画,之后div子元素的字体会抖一下
问题:给div设置background-color: rgba(0, 0, 0, 0.2)属性,并加了css3动画--opacity动画淡出动画,之后div子元素的字体会抖一下: 解决:animati ...
- sql模糊匹配中%、_的处理
防sql注入之模糊匹配中%._处理: StringBuilder sbSql = new StringBuilder(); sbSql.Append(@"SELECT * from tabl ...
- 记一次PHP7+opcache+zmq出现SIGSEGV 问题的查找(一次不成功的bug查找)
Title: 记一次PHP7+opcache+zmq出现SEGSEGV问题的查找(一次不成功的bug查找) bug来历自述:线上代码PHP环境是5.2,为了提升性能(逼格),于是升级为PHP7并使用 ...
- Sql Server 日期查询
当前月: USE [DBName] Go Use Database, Declare Variables DECLARE @ReportGenerationDate DATE DECLARE @Rep ...
- 当我我们用new操作符创建对象的时候,都发生了些什么?
//下面这段代码是javascript设计模式与开发实践上的一段代码 function Person( name ){ this.name = name; }; ...
- c++11 实现单例模式
C++11出来后,里面新增加了好多好用的功能 下面的单例就是使用了C++11中的标准库中的mutex和unique_prt 进行内存管理的. 此单例模式不用担心内存的释放问题 #pragma once ...
- pl/sql中文乱码问题解决
最近用pl/sql连我们公司的数据库,发现表里的中文数据都是“???”,上网查了一下,发现是数据库的编码格式和pl/sql的编码格式不统一造成的. 解决方法非常简单,只要创建一个系统环境变量:NLS_ ...
- UIScrollView的三个属性
contentSize.contentOffset.contentInset UIScrollView的frame的size 指的是可视范围 contentSize 内容大小,滚动的范围 创 ...
- 关于Java深clone 的例子学习
之前http://www.cnblogs.com/lhppom/p/4857702.html里有提到关于Java的深克隆的学习,深浅区别就是在于仅复制对象引用和复制对象引用所指向的对象,最近在看< ...
- 发现的eval的一个小问题
首先我们来看五段代码: 第一段代码: function test(){ eval('var a = 1;'); alert(a); } test(); 第二段代码: function test(){ ...