Moving Tables

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


Total Submission(s): 20344    Accepted Submission(s): 6900

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
 
Source
 #include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct ln{
int x;
int y;
}a[];
int main()
{
//freopen("in.txt","r",stdin);
int t;
int c[];
scanf("%d",&t);
while(t--)
{
memset(a,,sizeof(a));
memset(c,,sizeof(c));
int n,swap;
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
if(a[i].x%==)
a[i].x=a[i].x/;
else
a[i].x=a[i].x/+;
if(a[i].y%==)
a[i].y=a[i].y/;
else
a[i].y=a[i].y/+;
if(a[i].x>a[i].y)
{
swap=a[i].x;
a[i].x=a[i].y;
a[i].y=swap;
}
for(int j=a[i].x;j<=a[i].y;j++)
{
c[j]++;
}
}
//sort(a,a+n,cmp);
int max=;
for(int i=;i<=;i++)
{
if(c[i]>max)
max=c[i];
}
printf("%d\n",max*);
}
return ;
}
 

1050 Moving Tables的更多相关文章

  1. HDOJ 1050 Moving Tables

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

  2. hdoj 1050 Moving Tables【贪心区间覆盖】

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

  3. 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 ...

  4. hdu 1050 Moving Tables 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050 这道题目隔了很久才做出来的.一开始把判断走廊有重叠的算法都想错了.以为重叠只要满足,下一次mov ...

  5. HDU ACM 1050 Moving Tables

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

  6. Hdoj 1050.Moving Tables 题解

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

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

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

  8. hdu 1050 Moving Tables

    http://acm.hdu.edu.cn/showproblem.php?pid=1050 这个题我首先直接用的常规贪心,用的和那个尽可能看更多完整节目那种思路.但是.......一直WA....T ...

  9. HDU – 1050 Moving Tables

    http://acm.hdu.edu.cn/showproblem.php?pid=1050 当时这道题被放在了贪心专题,我又刚刚做了今年暑假不AC所以一开始就在想这肯定是个变过型的复杂贪心,但是后来 ...

随机推荐

  1. 《Mail电子邮件日志存储的管理》RedHat6.3——以一举三

    我们都知道很多日志的模块都是放在这下面的 要是想修改或是添加其他服务的日志,怎么办?修改下面的配置文件 测试下是否ok 轮转日志和定位分析和分析日志汇总报告: 安装logwatch软件包,这个没啥说的 ...

  2. ubuntu bash提示找不到文件或目录

    我在ubuntu上安装好后交叉编译器,用tab键也可以找到这个交叉编译器,但执行的时候总是提示:bash:xxx找不到文件或目录. 解决方法:安装lib32z1 命令:apt-get install ...

  3. php foreach 操作数组的代码

    php foreach 操作数组的代码.   foreach()有两种用法:  foreach(array_name as $value)  {  statement;  }  这里的array_na ...

  4. ASP.NET对HTML元素进行权限控制(三)

    上一篇博客中有些没有考虑到的东西这次更改一下代码如下: 界面前台: <%@ Page Language="C#" AutoEventWireup="true&quo ...

  5. ngnix 下配置多域名跳转 配置方法

    自己申请了多个域名,统一使用 http://goipc.cn/ 格式访问网站 server_name goipc.cn ; server_name www.goipc.cn ; server_name ...

  6. zip压缩包密码破解

    有一种破解方法叫做Known plaintext attack.市面上的密码破解软件几乎都带有这个功能.操作方法就是找到加密压缩包中的任意一个文件,用同样的压缩软件同样的压缩方式压缩成一个不加密的包, ...

  7. C++实现数字媒体二维图像变换

    C++实现数字媒体二维图像变换 必备环境 glut.h 头文件 glut32.lib 对象文件库 glut32.dll 动态连接库 程序说明 C++实现了用glut画正方形,画三角形的功能.并附带放大 ...

  8. 【CocoaPods】CocoaPods基本安装教程

    CocoaPods是什么,有什么用,怎么来等等我就不说了.反正就是一个管理第三方开源框架的~ 1. 配置前 - 本地安装好Ruby环境 2. 安装命令 -> sudo gem install c ...

  9. UpdateData(false) and UpdateData(true)

    数据更新函数: UpdateData(false); 控件的关联变量的值传给控件并改变控件状态(程序--->EXE) UpdateData(true); 控件的状态传给其关联的变量(EXE--- ...

  10. 多态&&父类调用子类特有的方法

    /* 多态 1.没有继承就没有多态 2.代码的体现:父类类型的指针指向子类对象 3.好处:如果函数\方法参数使用的是父类对象,可以传入父类.子类对象 4.局限性: 1>父类类型的变量,不能直接调 ...