在线编程在线课堂在线测评Anycodes在线编程

编程论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

How to use bs4??
本帖最后由 carry0987 于
Double Queue 问题描述 : The new founded Balkan Investment Group Bank (
John 问题描述 : Little John is playing very funny game
linux-command Linux命令大全搜索工具,内容包含Linux命令
Coati 是一款跨平台的代码查看工具,适用于 C/C++ 和 Java。商业软件。特性:1. 索引
系统可承载海量并发,消息收发确认机制 保障消息必达 系统采用动态智
全平台视频监控,支持安卓苹果以及pcweb,支持海康大华等主流dvr,全部源码以及文档 单聊、群聊、商
如何访问类的私有属性? 下面以 TPathData 为例,
问题:从 XE4 以来,Firemonkey 曲线绘图在移动平台不平滑的问题一直令人诟病,提交到官方的 QC 也是族繁不及备载,官方似乎有意的
操作数据库(RODBC)   odbcConnect(dsn, uid="", p
数据模式:mode函数显示任何对象的模式。常见的单个的
系统可承载海量并发,消息收发确认机制 保障消息必达 系统采用动态智
RabbitMQ与PHP(一) 项
Iease团队扩编预备中,盼望能有Ruby或者java工程师加盟。全职兼职都可以。有爱好的伴侣请与我接洽。 邮件:i
ruby 怎么设置装备摆设GTK2,求教指导下!
#include #include #include #include using namespace std; int main() {
标题如图所示: 有n盏灯,编号1~n。一开端灯都是关着的
成熟的消息收发确认机制,支持万人大群 支持开发自定义的消息sdk接口,扩展性超强 支持单/
成熟的消息收发确认机制,支持万人大群 支持开发自定义的消息sdk接口,扩展性超强 支持单/
1. 注意列表和集合的区别 set 列表表现形式: list_1
Ajax   Ajax即“Asynchronous Javascript And
大师好,我比来在做布谷鸟优
分辨提取A和B图像Harris角点,接下来须要对

[HDU杭电] HDU 1050 Moving Tables[解题报告] C++

[复制链接]
发表于 2016-3-25 22:13:46 | 显示全部楼层 |阅读模式
Moving Tables


问题描述 :
The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.

HDU 1050 Moving Tables[解题报告] C++

HDU 1050 Moving Tables[解题报告] C++
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.

HDU 1050 Moving Tables[解题报告] C++

HDU 1050 Moving Tables[解题报告] C++
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.
输入:
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.
输出:
The output should contain the minimum time in minutes to complete the moving, one per line.
样例输入:

  1. 3
  2. 4
  3. 10 20
  4. 30 40
  5. 50 60
  6. 70 80
  7. 2
  8. 1 3
  9. 2 200
  10. 3
  11. 10 100
  12. 20 80
  13. 30 50
复制代码
样例输出:

  1. 10
  2. 20
  3. 30
复制代码
<p align="left">2011-12-16 23:03:04<p align="left">地址:http://acm.hdu.edu.cn/showproblem.php?pid=1050<p align="left">题意:一个过道,旁边有如图所示分布的办公室。有n张桌子,分别要从s搬到t,每张桌子要搬10min,同一段过道内同一个时间只能有一张桌子存在。问最少需要的分钟数。<p align="left">mark:其实就是最大重叠数。wa了一次,注意同一个点出来的两张桌子,如果一个往左,一个往右,不可以同时进行。<p align="left">代码:
  1. # include <stdio.h>
  2. # include <stdlib.h>


  3. typedef struct node{
  4.     int a, b ;
  5. }node ;


  6. node pt[500] ;


  7. int min(int a, int b){return a<b?a:b;}
  8. int max(int a, int b){return a>b?a:b;}
  9. int cmp(const void *a, const void *b)
  10. {
  11.     node *p = (node*)a, *q = (node*)b ;
  12.     if (p->a != q->a) return p->a - q->a ;
  13.     return q->b - p->b ;
  14. }


  15. int main ()
  16. {
  17.     int i, T ;
  18.     int n, aa, bb, a, b ;
  19.     int ans, cur ;
  20.     scanf ("%d", &T) ;
  21.     while (T--)
  22.     {
  23.         scanf ("%d", &n);
  24.         for (i = 0; i < n ; i++)
  25.         {
  26.             scanf ("%d%d", &aa, &bb) ;
  27.             a = (min(aa,bb)+1) / 2 ;
  28.             b = (max(aa,bb)+1) / 2 ;
  29.             pt[i*2].a = a, pt[i*2].b = 1 ;
  30.             pt[i*2+1].a = b, pt[i*2+1].b = -1 ;
  31.         }
  32.         qsort(pt, n*2, sizeof(node), cmp) ;
  33.         ans = cur = 0 ;
  34.         for (i = 0 ; i < 2*n ; i++)
  35.         {
  36.             cur += pt[i].b ;
  37.             ans = max(ans, cur) ;
  38.         }
  39.         printf ("%d\n", ans*10) ;
  40.     }
  41.     return 0 ;
  42. }
复制代码
<p align="left">
在线编程(http://www.anycodes.cn)&编程论坛(http://www.52exe.cn)感谢您的支持!
回复

使用道具 举报

发布主题 上个主题 下个主题 快速回复 返回列表 官方QQ群
在线客服
客 服 中 心
群 机 器 人
网站二维码
收 起 客 服

QQ|Archiver|手机版|小黑屋|Anycodes ( ICP14002806Anycodes在线编程

GMT+8, 2018-11-22 01:08 , Processed in 1.703479 second(s), 71 queries .

Powered by Anycodes

© 2001-2013 吉林市群龙科技有限公司 Inc.

快速回复 返回顶部 返回列表