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 ...
随机推荐
- 数据库(学习整理)----1--如何彻底清除系统中Oracle的痕迹(重装Oracle时)
1.关于重装Oracle数据库: 由于以前装过Oracle数据库,但是版本不怎么样,结果过了试用期之后,我就没有破解和再找合适的版本了!直接使用电脑管家卸载了!可想而知,肯定没清除Oracle痕迹啊! ...
- Qt事件循环与状态机事件循环的思考
写下这个给自己备忘,关于事件循环以及多线程方面的东西我还需要多多学习.首先我们都知道程序有一个主线程,在GUI程序中这个主线程也叫GUI线程,图形和绘图相关的函数都是由主线程来提供.主线程有个事件循环 ...
- phpcms安装完成后总是跳转到install/install.php
很多人在本地安装phpcms后总是跳转到install/install.php.由于很多人是第一次使用phpcms,不知道为何会出现这个错误.出现这个大都是phpcms的缓存所致. 如何解决ph ...
- 知识管理(knowledge Management)2
①找到生命的主轴 ②跨领域知识管理
- "git add -A" is equivalent to "git add .; git add -u".
git add -A stages All git add . stages new and modified, without deleted git add -u stages modified ...
- f.lux亮度自动改变
笔记本在底光光镜下很刺眼,使用win7自带的亮度调节有的比较坑爹,我的Win+X里面没有亮度-! 使用f.lux可以自动根据时间调整光亮这一点很给力. 你,可以拥有.
- Hive的Metastore contains multiple versions
hive 客户端报错:Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeExcepti ...
- Hive的MoveTask错误
最近在部署Hive上线,结果在线上线下同时出现了MoveTask报错的现象,虽然两者错误的日志以及错误信息一样,但是经过分析解决又发现两者的原因是不一样的. 首先线下的错误日志: 2015-05-18 ...
- Dataguard配置前提条件
Data Guard配置前提条件 配置Data Guard必须保证以下前提条件: 1.Data Guard是Oracle企业版的组件.Oracle标准版里没有这个控件.所以Data Guard配置所使 ...
- The Model Complexity Myth
The Model Complexity Myth (or, Yes You Can Fit Models With More Parameters Than Data Points) An oft- ...