hdu1050Moving Tables(贪心)
Moving Tables
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 42736 Accepted Submission(s): 13986
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.
题意:有400个房间两边各200个,中间有一条走廊,在房间之间搬桌子,走廊的宽度只能容纳一张桌子,所以如果1号房间搬桌子到5号房间的时候二号房间就不能搬桌子,因为这块区域的走廊塞满了,但7号房间的走廊还是空的,可以搬,搬一次需要10分钟。问搬完给出的桌子需要多少时间。
题解:之间搬桌子的那块区域作为下标的数组值+10,每次都这样。最后这个数组中的最大值就是搬完所有桌子的时间。每次搬桌子的路径都可以看成是从低编号房间搬到高编号房间。这样方便为那块区域的数值+10,因为房间是面对面的,所以计算区域的时候可以从奇数编号房间到偶数编号房间。这样区域比较全。
#include<bits/stdc++.h>
using namespace std;
int a[];
int main() {
int t;
while(~scanf("%d",&t)) {
while(t--) {
int n;
memset(a,,sizeof(a));
scanf("%d",&n);
int maxx=;
for(int i=; i<n; i++) {
int start,end;
scanf("%d %d",&start,&end);
if(start>end)swap(start,end);
if(start%==) {
start-=;
}
if(end%)end+=;
for(int j=start; j<=end; j++) {
a[j]+=;
maxx=max(maxx,a[j]);
}
}
printf("%d\n",maxx);
} }
return ;
}
hdu1050Moving Tables(贪心)的更多相关文章
- Moving Tables(贪心或Dp POJ1083)
Moving Tables Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28304 Accepted: 9446 De ...
- zstu.2512. Moving Tables(贪心)
Moving Tables Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1182 Solved: 563 Description The famo ...
- HDU1050(Moving Tables:贪心算法)
解题思路: 这种做法是基于hdu2037的做法上考虑的,找出所有可以同时搬运的桌子,然后就很方便求出最短总时间. 还有一种更简单的做法是直接遍历一遍找出与别的重复次数最多的那片区域,重复次数*10就可 ...
- 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 贪心
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- --hdu 1050 Moving Tables(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050 AC code: #include<stdio.h> #include<str ...
- POJ 1083 && HDU 1050 Moving Tables (贪心)
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- hdoj 1050 Moving Tables【贪心区间覆盖】
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1050 Moving Tables (贪心)
题意:在一个走廊两边都有对称分布的连续房间,现在有n张桌子需要从a移动到b房间.每次移动需要10分钟, 但是如果两次移动中需要经过相同的走廊位置,则不能同时进行,需要分开移动.最后求最少需要多长时间移 ...
随机推荐
- js中返回上一页
<a class="btn btn-danger" href="javascript:history.go(-1);">取消</a>
- ASP.NET SingalR 点对点聊天实现思路总结
前一段时间写了一个简单的聊天室,是群聊的方式.博客地址:http://www.cnblogs.com/panzi/p/4980346.html.还有一种需求就是常见的尤其是培训机构的主页面,经常会有1 ...
- mybatis分步查询与延迟加载
1.分步查询 先查询用户的部门 部门Mapper.xml <resultMap id="rMap" type="com.yunqing.mybatis.bean.D ...
- 清空oracle session
select 'alter system kill session '''||sid|| ','||serial#||''';' from v$session where username =' ';
- Intellij IDEA如何删除项目
1. 删除某个项目 1) 选中项目,并关闭 2) File-Open,再选中相应的项目,并delete即可,它会同时在硬盘上删除
- 父窗口和iframe子窗口之间相互传递参数和调用函数或方法
1.父窗口向子窗口传递参数: 可以在url中添加参数:2.html?a=1&b=2&c=3 然后在子页面上可用js解析,提供一个函数: function getQueryStr(sAr ...
- Windows中杀死某个端口对应的进程
netstat -ano | findstr 3000 //列出进程极其占用的端口,且包含 3000 tasklist | findstr 17692 // 查看是什么程序占用的 taskkill - ...
- HttpClient请求地址并携带参数
废话不多,直接上代码! /** * * @param httpUrl * @param reqInfo * @return */ public static StringBuffer sendPost ...
- unittest单元测试框架之测试用例的跳过(skip) (六)
1.跳过测试用例的方法 @unittest.skip("don't run this case!"): @unittest.skipIf(3<2,"don't ru ...
- hdu 1394 Minimum Inversion Number(逆序数对) : 树状数组 O(nlogn)
http://acm.hdu.edu.cn/showproblem.php?pid=1394 //hdu 题目 Problem Description The inversion number ...