题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=1050

题目大意:
就说有一些桌子需要从某些房间搬到另一些房间,但中间只有一条走廊,且走廊中任何一段只能同时进行一次搬运。

思路:

由于有走廊有两边,可以尝试转换成同一边,比如我要从房间6搬到房间10,等价于我从房间5搬到房间9,这样转化之后问题变成了求多个区间的最大重叠次数,直接暴力就可以了,不过有一个坑点,题意只是说从房间x搬到房间y,没说x<y,所以x,y的大小不确定,暴力时需要进行判断。

 #include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#define FOR(i, a, b) for(int i = a; i < b; i++)
using namespace std;
int n, T;
int a[];
int main()
{
cin >> T;
while(T--)
{
memset(a, , sizeof(a));
cin >> n;
int x, y, ans = ;
while(n--)
{
cin >> x >> y;
if((x&) == )x--;
if((y&) == )y--;
//cout<<x<<" "<<y<<endl;
if(x > y)swap(x, y);
for(int i = x; i <= y; i+=)a[i]++;
}
for(int i = ; i <= ; i+=)ans = max(ans, a[i]);
cout<<ans*<<endl;
}
return ;
}

hdu1050 Moving Tables---贪心的更多相关文章

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

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

  2. Moving Tables(贪心或Dp POJ1083)

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

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

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

  4. Hdu1050 Moving Tables 2016-05-19 16:08 87人阅读 评论(0) 收藏

    Moving Tables Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floo ...

  5. hdu_1050 Moving Tables 贪心

    Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. 贪心算法训练(四)——(HDU1050)Moving Tables

    题目描述 在一个狭窄的走廊里将桌子从一个房间移动到另一个房间,走廊的宽度只能允许一个桌子通过.给出 t,表示有 t 组测试数据,再给出 n,表示要移动 n 个桌子.n 下面有 n 行,每行两个数字,表 ...

  7. UVAlive 2326 Moving Tables(贪心 + 区间问题)

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

  8. --hdu 1050 Moving Tables(贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050 AC code: #include<stdio.h> #include<str ...

  9. hdu1050 Moving Tables

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1050 求区间上点的最大重叠次数. #include <stdio.h> #include &l ...

  10. POJ 1083 &amp;&amp; HDU 1050 Moving Tables (贪心)

    Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

随机推荐

  1. 【转载】Perl中的引用

    为什么使用引用? 在perl4中,hash表中的value字段只能是scalar,而不能是list,这对于有些情况是很不方便的,比如有下面的数据: Chicago, USAFrankfurt, Ger ...

  2. 企业必会技能 tomcat

    企业必会技能 tomcat tomcat   一.什么是Tomcat? Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta项目中的一个核心项 ...

  3. Java中==与equals()的区别

    声明转载来源:http://blog.csdn.net/striverli/article/details/52997927 ==号和equals()方法都是比较是否相等的方法,那它们有什么区别和联系 ...

  4. USB Audio设计与实现

    1 前言 本文将基于STM32F4 Discovery板,从零开始设计并实现一个USB Audio的例子. 2 设计构思 所谓的USB AUDIO就是制作一个盒子,这个盒子可以通过USB连接到PC,P ...

  5. linux小白成长之路1————通过Parallels安装CentOS虚拟机

    以下是通过Mac版Parallels安装CentOS虚拟机的教程: 1.在Parallels向导中选择"下载CentOS",点击"继续":  2.点击&quo ...

  6. linux小白成长之路10————SpringBoot项目部署进阶

    [内容指引] war包部署: jar包部署: 基于Docker云部署. 一.war包部署 通过"云开发"平台初始化的SpringBoot项目默认采用jar形式打包,这也是我们推荐的 ...

  7. Leetcode 2——Range Sum Query - Mutable(树状数组实现)

    Problem: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), ...

  8. Beta开始前准备

    Beta准备 1. 讨论组长是否重选的议题和结论. 经过讨论,我们认为,经过一段时间的磨合,现任组长是不需要更换的. 2. 下一阶段需要改进完善的功能. 增加关于征信的功能,贴近选题主题 美化界面,尽 ...

  9. class AClass<E extends Comparable>与class AClass<E extends Comaprable<E>>有什么区别?

    new ArrayList<>()与new ArrayList()一样 都是为了做限定用的 如果不了解你可以看API 这个Comparable里面有一个方法compareTo(T o) 如 ...

  10. android批量打包

    http://blog.csdn.net/johnny901114/article/details/48714849