HDU1050:Moving Tables
pid=1050">Moving Tables
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19156 Accepted Submission(s): 6532

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.
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.
4
10 20
30 40
50 60
70 80
2
1 3
2 200
3
10 100
20 80
30 50
20
30
贪心题,左右两边数可看为一区间。求出最大的区间重叠数再乘以10就可以。。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue> using namespace std; const int maxn = 400 + 50; int cas;
int n;
int p, q;
int vis[maxn];
int ans_minute; int main()
{
scanf("%d", &cas);
while( cas-- )
{
scanf("%d", &n);
memset(vis, 0, sizeof(vis));
while( n-- )
{
scanf("%d%d", &p, &q);
p = (p-1) / 2;//压缩
q = (q-1) / 2;
if( p>q ) swap(p, q);
for(int i=p; i<=q; i++)vis[i]++;
}
int max_repeat = 1;
for(int i=0; i<200; i++)
if( vis[i]>max_repeat )
max_repeat = vis[i];
ans_minute = max_repeat * 10;
printf("%d\n", ans_minute);
}
}
HDU1050:Moving Tables的更多相关文章
- HDU1050(Moving Tables:贪心算法)
解题思路: 这种做法是基于hdu2037的做法上考虑的,找出所有可以同时搬运的桌子,然后就很方便求出最短总时间. 还有一种更简单的做法是直接遍历一遍找出与别的重复次数最多的那片区域,重复次数*10就可 ...
- Hdu1050 Moving Tables 2016-05-19 16:08 87人阅读 评论(0) 收藏
Moving Tables Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floo ...
- HDOJ 1050 Moving Tables
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- 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 ...
- uvalive 2326 - Moving Tables(区间覆盖问题)
题目连接:2326 - Moving Tables 题目大意:在一个走廊上有400个教室, 先在有一些桌子要移动, 每次移动需要十分钟, 但是不同房间的桌子可以在同一个十分钟内移动,只要走廊没有被占用 ...
- B - Moving Tables
B - Moving Tables Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- POJ1083 Moving Tables
POJ1083 Moving Tables Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35297 Accepted: ...
- POJ 1083 && HDU 1050 Moving Tables (贪心)
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
随机推荐
- [NOIP2013提高组]火柴排队
题目:洛谷P1966.Vijos P1842.codevs3286. 题目大意:有两排火柴,每根都有一个高度.设a.b分别表示两排火柴的高度,现在要令$\sum(a_i-b_i)^2$最小.现两排火柴 ...
- shell单引号屏蔽变量方法
[goforit ~]$ name="玖零後大叔" [goforit~]$ echo $name 玖零後大叔 [goforit ~]$ echo "$name" ...
- 如何创建一个可以使用try.....catch.......捕获的异常
代码很简单,大家一看基本上就能明白(有一定的java基础,熟悉try......catch.....finally的使用方法) package com.nokia.test1; public clas ...
- [HNOI2012]矿场搭建(割点)
[HNOI2012]矿场搭建 题目描述 煤矿工地可以看成是由隧道连接挖煤点组成的无向图.为安全起见,希望在工地发生事故时所有挖煤点的工人都能有一条出路逃到救援出口处.于是矿主决定在某些挖煤点设立救援出 ...
- [NOI2015]品酒大会(SA数组)
[NOI2015]品酒大会 题目描述 一年一度的"幻影阁夏日品酒大会"隆重开幕了.大会包含品尝和趣味挑战 两个环节,分别向优胜者颁发"首席品酒家"和" ...
- HDU 4398 Template Library Management (最优页面调度算法)
中等偏易题.操作系统理论中的最优页面调度算法,贪心.当需要淘汰某个模版时,淘汰掉当前手中在最远的将来才会被用到(或者以后永远不再用到)的那个. 代码: #include <iostream> ...
- 使用YUM安装ZABBIX监控
http://blog.csdn.net/aqw123456fdg/article/details/48135477 http://www.cnblogs.com/enjoycode/p/zabbix ...
- 在启动php时,无法启动此程序,由于计算机中丢失MSVCR110.dll的解决方法
在启动php时,运行RunHiddenconsole.exe php-cgi.exe -b 127.0.0.1:9000 -c时,出现错误:无法启动此程序,由于计算机中丢失MSVCR110.dll 方 ...
- iOS 一个ViewController上显示2个tableView的方法
1.在StoryBoard上创建2个tableView,并用autolayout约束. 2.在ViewController上拖进来. @property (weak, nonatomic) IBOut ...
- hdoj--1342--Lotto(dfs)
Lotto Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...