http://acm.hdu.edu.cn/showproblem.php?

pid=1050

Moving Tables

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 18850    Accepted Submission(s): 6440

Problem Description
The famous ACM (Advanced Computer Maker) Company has 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.

 
Input
The input consists of T test cases. The number of test 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.
 
Output
The output should contain the minimum time in minutes to complete the moving, one per line.
 
Sample Input
3
4
10 20
30 40
50 60
70 80
2
1 3
2 200
3
10 100
20 80
30 50
 
Sample Output
10
20
30
 

简单贪心题,找重叠次数最多的部分。
AC代码:
<span style="font-size:18px;">#include<stdio.h>
#include<string.h>
int a[201];
int main()
{
int n,b,i,m,p,q,t,j,k;
scanf("%d",&n);
for(t=0;t<n;t++)
{
memset(a,0,sizeof(a));
scanf("%d",&b);
for(i=1;i<=b;i++)
{
scanf("%d %d",&p,&q);
p=(p-1)/2;//缩小
q=(q-1)/2;
if(p>q)//确保q大于p
{
m=p;
p=q;
q=m;
}
for(j=p;j<=q;j++)
a[j]++; //标记
}
k=1;
for(j=0;j<200;j++)
if(a[j]>k)//重叠次数最多的
k=a[j];
printf("%d\n",k*10);
} return 0;
}</span>

杭电 1150 moving tables的更多相关文章

  1. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  2. HDU ACM 1050 Moving Tables

    Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a buildin ...

  3. 杭电ACM题单

    杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最 ...

  4. acm入门 杭电1001题 有关溢出的考虑

    最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...

  5. 杭电acm 1002 大数模板(一)

    从杭电第一题开始A,发现做到1002就不会了,经过几天时间终于A出来了,顺便整理了一下关于大数的东西 其实这是刘汝佳老师在<算法竞赛 经典入门 第二版> 中所讲的模板,代码原封不动写上的, ...

  6. 杭电OJ——1198 Farm Irrigation (并查集)

    畅通工程 Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标是使全省任何两个城镇间都可 ...

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

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

  8. Moving Tables(贪心或Dp POJ1083)

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

  9. 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”

    按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...

随机推荐

  1. C#对象初始化的探讨

    最近在弄MQ的性能监测数据埋点,无疑中用到一个Nstatsd的客户端,看到里面写过里面一种嵌套类的写法.代码如下: 客户端Client是一个密封的类,并且构造函数私有访问.然后又用一个嵌套类Curre ...

  2. Installing MySQL 5.7.23 on CentOS 7

    Installing MySQL 5.7.23 on CentOS 7 1. 安装前检查 1.1 检查NUMA是否开启 NUMA为什么要咋MySQL中禁用? MySQL是单进程多线程架构数据库,当nu ...

  3. python-----定制群发微信消息

    如何使用表格中的信息群发微信消息? 如何读取csv? →   使用内置模块csv 如何按对应信息发送到微信?→  使用第三方库wxpy 以下代码素材自取:链接:https://pan.baidu.co ...

  4. 【HIHOCODER 1105】题外话·堆

    描述 小Ho有一个糖果盒子,每过一段时间小Ho都会将新买来的糖果放进去,同时他也会不断的从其中挑选出最大的糖果出来吃掉,但是寻找最大的糖果不是一件非常简单的事情,所以小Ho希望能够用计算机来他帮忙计算 ...

  5. 理解js的几个关键问题(1):全局变量new和关于hasOwnPropery和PropertyIsEnumerable 等

    一.作用域和全局变量 var test=function(){ var a=1; setTimeout(function(){ console.log(a); a=2; },1000); a=3; s ...

  6. xtu summer individual 3 C.Infinite Maze

    B. Infinite Maze time limit per test  2 seconds memory limit per test  256 megabytes input standard ...

  7. php引入PHPMailer发送邮件

    昨天做了一个发送邮件的功能,如果直接用mail()函数,需要拥有自己的邮件服务器,所有引入PHPMailer类方便快捷,简单写一下开发步骤: 一.拥有自己的邮箱账号(作为发件人邮箱) 分两种情况: 1 ...

  8. CentOS6 CentOS7 yum安装图形界面

    CentOS6 yum安装图形界面yum groupinstall -y "Desktop" "Desktop Platform" "Desktop ...

  9. poj 3678 XOR和OR和AND(简单2-sat问题)

    /* 题意:给你一些边,每条边有一个值和一个运算符XOR OR AND求是否存在一些点使得所有的边根据这些运算符 可以符合条件的权值. 建边方式参考:http://blog.csdn.net/shua ...

  10. 巴蜀3540 -- 【Violet 6 最终话】蒲公英

    Description 原题的时间限制是 2s . 亲爱的哥哥: 你在那个城市里面过得好吗? 我在家里面最近很开心呢.昨天晚上奶奶给我讲了那个叫「绝望」的大坏蛋的故事的说!它把人们的房子和田地搞坏,还 ...