题目链接:http://poj.org/problem?id=1083

如图所示在一条走廊的两侧各有200个房间,现在给定一些成对的房间相互交换桌子,但是走廊每次只能通过一组搬运,
也就是说如果两个搬运过程有交叉是不能同时搬运的,要依次来,一次搬运10min,问完成所有的搬运的最少用时。
 
思路:将每个左右相邻房间的走廊作为一个统计单位,当所有的办公桌都搬运完成后,检查每个走廊对应的统计单位被占用多少次。
统计所有的左右相邻房间的走廊被占用的最大次数,就是单独安排的搬运次数,乘以10就是总的搬运时间。
另外,将from和to做-1 mod 2 处理是为了与数组下标对应起来,方便处理
 #include <iostream>
#include <algorithm>
#include <functional>
#include <string.h>
#include <cstdio>
using namespace std; int main()
{
int t = ;
cin >> t;
while (t-- > )
{
// 每两个房间之间一个走廊,总共200个走廊
int move[];
int n = ; // 搬运次数
cin >> n;
memset(move, , sizeof(move));
for (int i = ; i < n; i++)
{
int from = , to = ;
cin >> from >> to;
from = (from - ) / ;
to = (to - ) / ;
if (to < from)
{
swap(from, to);
}
for (int j = from; j <= to; j++)
{
move[j]++;
}
}
int max = ;
for (int i = ; i < ; i++)
{
if (move[i] > max)
{
max = move[i];
}
}
cout << max * << "\n";
}
return ;
}

POJ1083(Moving Tables)--简单模拟的更多相关文章

  1. POJ1083 Moving Tables(模拟)

    The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in ...

  2. POJ1083 Moving Tables

    POJ1083 Moving Tables Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 35297   Accepted: ...

  3. 解题报告:poj1083 Moving tables

    2017-09-02 19:49:59 writer:pprp 题意说明: 比较简单的题,一开始被吓到了,后来才发现,其实可以用很简单的方法就可以解决: 就是在这样的房间中如果在i 和 j 中之后的1 ...

  4. Moving Tables(贪心或Dp POJ1083)

    Moving Tables Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28304   Accepted: 9446 De ...

  5. HDU1050(Moving Tables:贪心算法)

    解题思路: 这种做法是基于hdu2037的做法上考虑的,找出所有可以同时搬运的桌子,然后就很方便求出最短总时间. 还有一种更简单的做法是直接遍历一遍找出与别的重复次数最多的那片区域,重复次数*10就可 ...

  6. 杭电 1150 moving tables

    http://acm.hdu.edu.cn/showproblem.php? pid=1050 Moving Tables Time Limit: 2000/1000 MS (Java/Others) ...

  7. java web学习总结(二十二) -------------------简单模拟SpringMVC

    在Spring MVC中,将一个普通的java类标注上Controller注解之后,再将类中的方法使用RequestMapping注解标注,那么这个普通的java类就够处理Web请求,示例代码如下: ...

  8. WPF简单模拟QQ登录背景动画

    介绍 之所以说是简单模拟,是因为我不知道QQ登录背景动画是怎么实现的.这里是通过一些办法把它简化了,做成了类似的效果 效果图 大体思路 首先把背景看成是一个4行8列的点的阵距,X轴Y轴都是距离70.把 ...

  9. zstu.2512. Moving Tables(贪心)

     Moving Tables Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 1182  Solved: 563 Description The famo ...

随机推荐

  1. keras 在train_on_batch中启用tensorboard

    def write_log(callback, names, logs, batch_no): for name, value in zip(names, logs): summary = tf.Su ...

  2. Docs-.NET-C#-指南-语言参考-预处理器指令:#error(C# 参考)

    ylbtech-Docs-.NET-C#-指南-语言参考-预处理器指令:#error(C# 参考) 1.返回顶部 1. #error(C# 参考) 2015/07/20 #error 可从代码中的特定 ...

  3. 【转载】 AutoML技术现状与未来展望

    原文地址: https://www.cnblogs.com/marsggbo/p/9309520.html ---------------------------------------------- ...

  4. Tomcat监听shutdown释放数据库连接池

    开发时因为更新代码,频繁重启Tomcat,遇到一个问题:在执行shutdown脚本后,Tomcat进程没有关闭依然存在(但是HTTP服务已经停止),需要手动执行kill命令才行.查了一些资料结合经验, ...

  5. IDEA新建本地项目关联远程git仓库

    现在远程git仓库创建一个repository,然后本地创建项目,最后进行关联.三板斧,打完收工. 第一步.第二步地球人都知道,略过不表,第三步比较关键,举个例子: 0.创建本地Git仓库:VCS - ...

  6. java读取request中的xml

    java读取request中的xml   答: // 读取xml InputStream inputStream; StringBuffer sb = new StringBuffer(); inpu ...

  7. LeetCode_110. Balanced Binary Tree

    110. Balanced Binary Tree Easy Given a binary tree, determine if it is height-balanced. For this pro ...

  8. LeetCode_27. Remove Element

    27. Remove Element Easy Given an array nums and a value val, remove all instances of that value in-p ...

  9. Spring Cloud(8):日志及分布式跟踪(Sleuth&Zipkin)

    简介 在微服务架构中,项目中前端发起一个请求,后端可能跨几个服务调用才能完成这个请求.如果系统越来越庞大,服务之间的调用与被调用关系就会变得很复杂,那么这时候我们需要分析具体哪一个服务出问题了就会显得 ...

  10. React中的setState到底发生了什么?

    https://yq.aliyun.com/ziliao/301671 https://segmentfault.com/a/1190000014498196 https://blog.csdn.ne ...