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分钟, 但是如果两次移动中需要经过相同的走廊位置,则不能同时进行,需要分开移动.最后求最少需要多长时间移 ...
随机推荐
- ASP.NET SingalR + MongoDB 实现简单聊天室(二):实现用户信息、聊天室初始化,聊天信息展示完善
第一篇已经介绍了一大半了,下面就是详细业务了,其实业务部分要注意的地方有几个,剩下的就是js跟html互动处理. 首先在强调一下,页面上不可缺少的js:jquery,singalR.js,hubs . ...
- Fine Tuning
(转载自:WikiPedia) Fine tuning is a process to take a network model that has already been trained for a ...
- IBAction作用相当于void,NSLog(@"被调用的方法名是%s",__func__);
IBAction作用相当于void,NSLog(@"被调用的方法名是%s",__func__);
- js 获取任意一个元素的任意一个样式属性的值
//谷歌,火狐支持console.log(window.getComputedStyle(my$("dv"),null).left);//IE8支持console.log(my$( ...
- JavaScript手绘风格的图形库RoughJS使用指南
RoughJS是一个轻量级的JavaScript图形库(压缩后约9KB),可以让你在网页上绘制素描风格.手绘样式般的图形.RoughJS定义了绘制直线,曲线,圆弧,多边形,圆和椭圆的图元,同时它还支持 ...
- PHP curl 携带cookie请求抓取源码,模拟登陆。
公司需要采集一批手机号码,有指定网站.但是需要登陆后才能看到客户号码,手动点击复制太慢,如此就写了以下模拟登陆采集号码程序,分享给大家参考参考. function request_url_data($ ...
- shell中的死记硬背
一.shell的引号们 1."" -> 双引号(不保留完整内容,比如遇到$, 反引号, \ 等就会执行相应的shell) echo "Today is `date` ...
- 『Linux基础 - 3』 Linux文件目录介绍
Windows 和 Linux 文件系统区别 -- 结构 Windows 下的文件系统 - 在 Windows 下,打开 "计算机",我们看到的是一个个的驱动器盘符: - 每个驱动 ...
- 通过burpsuite替换cookie登录后台
通过burpsuite可以比较方便的替换http头部的cookie.useragent等字段,在获取到用户的cookie后实现登录.具体使用方法如下: 如替换cookie,可以写正则表达式^Cooki ...
- 用elk+filebeat监控容器日志
elk 为 elasticsearch(查询搜索引擎),logstash(对日志进行分析和过滤,然后转发给elasticsearch),kibana(一个web图形界面用于可视化elasticsea ...