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
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<stdlib.h>
  4. #include<string.h>
  5. #include<iostream>
  6. #include<algorithm>
  7. using namespace std;
  8. struct ln{
  9. int x;
  10. int y;
  11. }a[];
  12. int main()
  13. {
  14. //freopen("in.txt","r",stdin);
  15. int t;
  16. int c[];
  17. scanf("%d",&t);
  18. while(t--)
  19. {
  20. memset(a,,sizeof(a));
  21. memset(c,,sizeof(c));
  22. int n,swap;
  23. scanf("%d",&n);
  24. for(int i=;i<n;i++)
  25. {
  26. scanf("%d%d",&a[i].x,&a[i].y);
  27. if(a[i].x%==)
  28. a[i].x=a[i].x/;
  29. else
  30. a[i].x=a[i].x/+;
  31. if(a[i].y%==)
  32. a[i].y=a[i].y/;
  33. else
  34. a[i].y=a[i].y/+;
  35. if(a[i].x>a[i].y)
  36. {
  37. swap=a[i].x;
  38. a[i].x=a[i].y;
  39. a[i].y=swap;
  40. }
  41. for(int j=a[i].x;j<=a[i].y;j++)
  42. {
  43. c[j]++;
  44. }
  45. }
  46. //sort(a,a+n,cmp);
  47. int max=;
  48. for(int i=;i<=;i++)
  49. {
  50. if(c[i]>max)
  51. max=c[i];
  52. }
  53. printf("%d\n",max*);
  54. }
  55. return ;
  56. }
 

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. Linux下iftop网卡流量监控使用

    在类linux系统中可以使用top查看系统资源.进程.内存占用等信息.查看网络状态可以使用netstat.nmap等工具.若要查看实时的网络流量,监控TCP/IP连接等,则可以使用iftop. 一.i ...

  2. silverlight 文本框只能输入汉字

    private void txtName_KeyDown(object sender, KeyEventArgs e) { Regex rg = new Regex("^[\u4e00-\u ...

  3. Unity3d 动态批处理的问题

    这段时间做unity3d的优化,主要的入手是减少draw call.    1.代码上主要是把一些零碎的同材质的合并成一个大的mesh.    2.减少不必要的全屏后期处理.把摄像机的renderin ...

  4. ios 录音

    http://code4app.com/ios/%E5%BD%95%E9%9F%B3%E5%92%8C%E6%92%AD%E6%94%BE/51ba821b6803fa6901000000

  5. C#实现斐波那契数列求和

    一个比较典型的递归调用问题,总结一下.网上看了一个链接,比较好:http://blog.csdn.net/csd_xiaojin/article/details/7945589 贴个图先,回头再整理: ...

  6. 【面试虐菜】—— Jboss调优

    吐血整理了以前Jboss以及JVM在生产环境下的调优参数,各种不同的案例,都是来自网友杜撰.整合后,希望对广大使用jboss作为生产应用服务器的朋友有所帮助. JBOSS参数调优 配置deploy/j ...

  7. TLV格式是什么格式

    TLV 格式是什么格式 一种可变格式, TLV 的意思就是: Type 类型, Lenght 长度, Value 值: Type 和 Length 的长度固定,一般那是 2 . 4 个字节: Valu ...

  8. xv6实验环境搭建

    安装bochs 因为要运行的是xv6,所以不能直接使用 apt-get 直接获取软件.apt-get获取到的软件不支持SMP (Symmetric Multi-Processing).因此,需要下载源 ...

  9. Java eclipse export jar包 包括第三方引入的jar

    1.安装fatjar插件 2.export jar 说明:安装后,操作说明以官网为准,不同的版本会有不同的右键菜单,我的版本(Eclipse Java EE IDE for Web Developer ...

  10. linux内核中的get_user和put_user

    linux内核中的get_user和put_user 在 内核空间和用户空间交换数据时,get_user和put_user是两个两用的函数.相对于copy_to_user和 copy_from_use ...