hdoj 1050 Moving Tables【贪心区间覆盖】
Moving Tables
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 24316 Accepted Submission(s):
8053
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.
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.
to complete the moving, one per line.
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 1100
using namespace std;
int dp[MAX];
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
int n,t,m,i,j;
scanf("%d",&t);
int a,b,c;
while(t--)
{
scanf("%d",&n);
memset(dp,0,sizeof(dp));
for(i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
if(a>b)
{
c=a;
a=b;
b=c;
}
a=(a+1)/2;
b=(b+1)/2;
for(j=a;j<=b;j++)
{
dp[j]++;
}
}
sort(dp,dp+200,cmp);
printf("%d\n",dp[0]*10);
}
return 0;
}
hdoj 1050 Moving Tables【贪心区间覆盖】的更多相关文章
- HDOJ 1050 Moving Tables
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- Hdoj 1050.Moving Tables 题解
Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a buildin ...
- UVAlive 2326 Moving Tables(贪心 + 区间问题)
The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in ...
- --hdu 1050 Moving Tables(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050 AC code: #include<stdio.h> #include<str ...
- 高效算法——E - 贪心-- 区间覆盖
E - 贪心-- 区间覆盖 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/E 解题思路: 贪心思想, ...
- 【题解】Cut the Sequence(贪心区间覆盖)
[题解]Cut the Sequence(贪心区间覆盖) POJ - 3017 题意: 给定一大堆线段,问用这些线段覆盖一个连续区间1-x的最小使用线段的数量. 题解 考虑一个这样的贪心: 先按照左端 ...
- POJ 1083 && HDU 1050 Moving Tables (贪心)
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- HDU – 1050 Moving Tables
http://acm.hdu.edu.cn/showproblem.php?pid=1050 当时这道题被放在了贪心专题,我又刚刚做了今年暑假不AC所以一开始就在想这肯定是个变过型的复杂贪心,但是后来 ...
- hdu_1050 Moving Tables 贪心
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
随机推荐
- Win32 GDI 非矩形区域剪裁,双缓冲技术
传统的Win32通过GDI提供图形显示的功能,包括了基本的绘图功能,如画线.方块.椭圆等等,高级功能包括了多边形和Bezier的绘制.这样app就不用关心那些图形学的细节了,有点类似于UNIX上的X- ...
- URL 路由访问报错
错误: 错误分析: 控制器的文件名命名有问题(index.php) 在TP中控制器命名规范(IndexController.class.php) 相信许多PHP开发者在使用ThinkPHP ...
- jQuery 标签淡入淡出 个人随笔
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- div模块变灰
整站变灰目前没发现什么特别好的办法,但是div(或者其他标签模块)模块变灰方法兼容性还不错. .gay_box{ filter: grayscale(100%); -webkit-filter: gr ...
- Maven介绍,包括作用、核心概念、用法、常用命令、扩展及配置
由浅入深,主要介绍maven的用途.核心概念(Pom.Repositories.Artifact.Build Lifecycle.Goal).用法(Archetype意义及创建各种项目).maven常 ...
- Cinder-2 窗口的创建过程
通过TinderBox生成的代码很简单,整个代码如下: #include "cinder/app/AppNative.h" #include "cinder/gl/gl. ...
- string与char* 互相转换以及周边问题
先插一个小知识点 string str = "abc" str += 'd'; cout<<str<<endl; //"abcd" ...
- 关于applicationx/www-form-urlencoded和multipart/form-data的描述
在Form元素的语法中,EncType表明提交数据的格式 用 Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型. 下边是说明: application/x-www-form-urlen ...
- Application(全局对象,ViewState
Application对象生存期和Web应用程序生存期一样长,生存期从Web应用程序网页被访问开始,HttpApplication类对象Application被自动创建,直到没有一个网页被访问时结束, ...
- Struts_json插件配置参数
Struts中使用json需要在struts基础上加上几个包:(这里只列出了重要的几个) commons-lang-2.4.jar: jsonplugin-0[1].32.jar: 下面是配置文件中的 ...