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 ...
随机推荐
- C#获取数组的行和列数程序代码
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- Linq 构造复杂Json 多表group by
一个主表A(a1,a2),子表B(a1,b1,b2) ,想得到的结果是 [{a1,a2,Info [{b1,b2},{b1,b2},...}]] var list= from a in A join ...
- 网页解析Jsoup简单使用
public static void main(String[] args) throws IOException { //System.out.println("Hello World!& ...
- JavaScript拖拽
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta http-e ...
- O(1)检测2的幂次
class Solution { public: /* * @param n: An integer * @return: True or false */ bool checkPowerOf2(in ...
- BenchmarkDotNet
.NET Core性能测试组件BenchmarkDotNet 支持.NET Framework Mono .NET Core 超强性能测试组件BenchmarkDotNet 支持Full .NET F ...
- Javascript AMD模块化规范-备用
AMD是"Asynchronous Module Definition"的缩写,意思是"异步模块定义". 模块定义define(id?, dependencie ...
- 我的前端之旅--SeaJs基础和spm编译工具运用[图文]
标签:seajs nodejs npm spm js 1. 概述 本文章来源于本人在项目的实际应用中写下的记录.因初期在安装和使用Seajs和SPM的时候,有点不知所措的经历.为此,我 ...
- 【技术贴】解决myeclipse SVN 提交代码 commit:remains in tree-c
[技术贴]解决myeclipse SVN 提交代码 commit:remains in tree-conflict错误的解决办法 错误是:Aborting commit: xxxxx' remains ...
- 减少 WAF 漏报的 8 种方法 !
近十年来,WAF 已经逐渐发展成熟,被软件行业接受并成为无数企业保护应用的不二选择.很多大型企业甚至相继亲自设计或通过并购涉足其中,在这个硕大的市场里逐鹿竞争,同时也推动了应用层防火墙的技术演进. 与 ...