Moving Tables

moving Tables java 实现moving Tables 立即下载

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.

这里写图片描述
Table moving
Reason
Possible
( room 30 to room 50) and (room 60 to room 90)
no part of corridor is shared
(room 11 to room 12) and (room 14 to room 13)
no part of corridor is shared
Impossible
(room 20 to room 40) and (room 31 to room 80)
corridor in front of room 31 to room 40 is shared
(room 1 to room 4) and (room 3 to room 6)
corridor in front of room 3 is shared
(room 2 to room 8) and (room 7 to room 10)
corridor in front of room 7 is shared

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

样例输入
3
4
10 20
30 40
50 60
70 80
2
1 3
2 200
3
10 100
20 80
30 50
样例输出
10
20
30

题目不难,英文有些难以理解。
题目意思就是从两个不同的房间移桌子,移动桌子需要占用房间之间的过道,占用一次需要10分钟,问至少需要多少时间。
以最后一次输入为例
用数组a[200]初始化为0
3
10 100 经过 5-50过道 这过道的值都+1
20 80 经过 10-80过道

这过道的值都+1
30 50

经过 15-25过道 这过道的值都+1
扫一遍 寻找 a[200]中的最大值 发现 15-25 这10个数都是3 最大 即 15-25这个过道必须得被占用3次
用 3*10(time)就可得出正确结论

#include<stdio.h>
int main()
{
    int x,s,n,t,i,temp;
    scanf("%d",&x);
    while(x--)
    {
        int ans[300]={0};
        //memset(ans,0,sizeof(ans));另一种初始化数组值为0的方法
        scanf("%d",&n);
        while(n--)
        {
            scanf("%d %d",&s,&t);
            if(s>t)
            {
                temp=t;t=s;s=temp;
            }
            for(i=(s+1)/2;i<=(t+1)/2;i++)
            {
                ans[i]++;
            }
        }
        int max=0;
        for(i=1;i<=200;i++)
        {
            if(max<ans[i])
            {
                max=ans[i];
            }
        }
        printf("%d\n",max*10);
    }
} 

memset(a,0,sizeof(a))意思就是将a数组所有值初始为0;
这里初始值只能是0或-1;
因为memset是对每个字节赋值,而int有4字节(32位)
比如这样,memset(a,1,sizeof(a));
则a中的每个元素都被赋值成为2进制数为00000001000000010000000100000001的数
转换成10进制就是16843009
所以,一般用memset对数组赋0或-1,赋其他的值就要用循环来实现。
用int a[10]={0};也可以初始化所有值为0;
int a[10]={10};意思为a[0]的值为10,其他值为0;

Python爬取腾讯视频m3u8加密流实战(附完整代码) 本文提供了一份详细的Python实战教程,指导如何通过抓包分析、模拟请求头与载荷,破解腾讯视频的m3u8加密流防盗链机制,并附上完整代码实现视频片段的下载与合并。教程涵盖从侦察到代码实现的完整流程,并包含参数动态化、多线程下载等高级技巧与避坑指南,旨在帮助开发者掌握流媒体下载的核心技术。 阅读详情

相关推荐

Multisim14.3中FPGA接口电路设计:原理图项目应用

深入讲解在multisim14.3环境下构建FPGA接口电路的方法,结合原理图设计与项目实践,展现multisim14.3强大的电路仿真能力,提升数字系统开发效率。

weixin_42578963的博客 1161

Moving Tables ——经典贪心和区间覆盖问题

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

mumei的博客 894

FOFA奇技淫巧:从搜索语法到实战场景的深度挖掘

本文深入探讨了FOFA搜索语法在网络空间测绘中的高效应用,从基础语法到实战场景的深度挖掘。通过渗透测试、威胁狩猎、资产发现等实际案例,展示了如何利用FOFA精准定位目标系统、识别蜜罐、追踪威胁,并提供了合规使用指南和性能优化技巧,助力安全工作者提升效率。

weixin_32428571的博客 243

Moving Tables(贪心算法)

题目描述 著名的ACM公司租用了一幢楼的一层,其形状如下。 整个楼层在走廊的北面和南面各有300个房间。最近公司制定了一个改变布局的方案,包括在不同房间之间移动许多桌子。由于走廊狭窄,而且桌子都很大,只有一张桌子可以穿过走廊。为了提高工作效率,经理制定了如下方案:把一张桌子从一个房间搬到另一个房间可以在5分钟内完成。当移动一张桌子从I房间搬到J房间时,房间I前面和房间J前面的走廊部分被使用了。因此,在每5分钟,在不共用走廊的情况下,不同的移动方案可以同时进行。为了说明问题,经理举例说明了可能发生的情况和不可

weixin_47511190的博客 2098

18、未来医疗信息学中的太赫兹天线技术

本文探讨了太赫兹天线技术在医疗信息学中的关键作用,重点分析了分裂环谐振器和纳米结构光导天线(PCA)的设计与性能提升方法,介绍了相干与非相干太赫兹检测技术,并通过等效电路模型和数值模拟深入解析PCA工作机理。文章还展示了太赫兹技术在无创血糖监测、肿瘤检测等医疗诊断中的实验应用,总结了其非侵入性、高分辨率成像和多参数分析等优势,同时指出信号检测难、成本高和技术复杂等挑战。未来趋势包括设备小型化、效率提升及与人工智能融合,拓展至药物研发、皮肤与神经疾病诊断等领域,展现出变革医疗健康的巨大潜力。

milk8的博客 149

Arduino ESP8266通过 RF433数据收发实验

Arduino ESP8266通过 RF433射频模块实现数据收发实验 写这篇文章,折腾了2天,在没有成功之前,一直在摸索和采坑当中,不要问我黑暗和黎明之间有多长。开发很多时候只问结果,不问过程的,在这里分享来之不易的结果,希望后面的人不要采坑,有成功的案例先河,后面与之相关的应用开发只需要套用模板修改即可实现。 实物搭建 RF433模块 我使用的是这个:nodemcu 本案例开发所使用到的库:RadioHead:http://www.airspayce.com/mikem/

perseverance51博客 3815

Moving Tables贪心

题目:传送门 大概意思就是说:有一条走廊,两边各有两百个总共四百个房间(有编号的),任务是在这些房间之间移动桌子。当一张桌子从房间 s 移动到房间 t,那它们之间的走廊部分就被征用了,这部分的房间就不可以移动桌子,其他部分的房间可以移动桌子。移动一张桌子需要十分钟,求最短的移动桌子所花的时间。 思路:用数组mark标记走廊位置被标记的次数,若移动多个桌子时,所需要经过的走廊没有重合处,即可以同时移动。若有一段走廊有m个桌子都要经过,一次只能经过一个桌子,走过的走廊都要被标记一次,走廊被经过最多的次数乘以时间

G191018的博客 342

Microsemi Libero系列教程(一)——Libero开发环境介绍、下载、安装与注册

前言 相比与Xilinx和Altera在国内的市场,Microsemi的FPGA在国内应用很少很少,网上几乎没有详细的教程,刚开始使用时,遇到了各种问题,自己也走了不少弯路。本系列教程以Libero V11.8.2.4,SmartFusion系列A2F200M3F FPGA芯片为例,将详细介绍Libero SoC软件的基本使用,及使用过程中遇到一些问题的解决方法。 Libero 简介 关于Lib...

whik1194的博客 3万+

算法-------moving tables

下图是著名的ACM(高级计算机制造商)公司租用的建筑物的地板。 该楼层在走廊的北侧和南侧各有200个房间。最近,公司制定了改革其系统的计划。改革包括在房间之间移动很多桌子。由于走廊狭窄且所有桌子都很大,因此只有一张桌子可以穿过走廊。需要一些计划来提高移动效率。经理制定了以下计划:将桌子从一个房间移到另一个房间可以在10分钟内完成。将桌子从房间i移到房间j时,将使用房间i的正面和房间j的正面之间的走廊部分。因此,在每10分钟内,将在不共享走廊同一部分的两个房间之间同时移动几个房间。为了清楚起见,经理说明了同

weixin_43846020的博客 597

【招商银行笔试题汇总】[全网首发]2024-04-23-招商银行春秋招笔试题-三语言题解(CPP/Python/Java)

🏳️ 难难难!!!本次招商银行的笔试算是今年春招最难的场次之一了K小姐所在的公司有 NNN 个部门,编号从 111 到 NNN。由于公司网络系统比较老旧,对于同一个数据 ddd,不同部门记录的值可能不同。数据 ddd 在各部门被记录为 d1,d2,...,dNd_1, d_2, ..., d_Nd1​,d2​,...,dN​。公司提出可以通过会议来实现数据的一致性。每次会议会让相邻编号范围内的所有部门一起参加,如果有超过半数的部门能够对数据 ddd 的值达成共识,那么在此次会议后,参与会议的所有部门会将

春秋招笔试突围 3476

《爬虫和逆向教程》 - 专栏介绍和目录

本专栏为爬虫初学者和进阶开发者量身定制的爬虫和逆向学习园地。为你提供全面而深入的爬虫和逆向技术指导,从入门到精通,从基础理论到高级实战,助你在数据的海洋中畅游,挖掘出有价值的信息。通过本专栏的学习,你将具备独立开发和优化爬虫程序的能力,及逆向分析能力和项目开发能力,成为爬虫领域的佼佼者。

数据知道的博客 2万+

【HDOJ】1050 moving tables

2.对于两次搬运而言,上一次的end和下一次的begin相同时是可以搬到,没有重叠的走廊空间。3.begin不一定小于end,他可能反着搬,即从房间序号大的搬到房间序号小的。杭电oj里的moving tables问题,可以用贪心算法解决。1.每次循环过后记得重定义ismoved为0.

Coyilla的博客 343

【重温童年】基于tkinter模块设计的Q宠大乐斗武器升星模拟器:重温经典,畅享休闲时光

与传统的Q宠大乐斗不同,这款模拟器还加入了一个创新的功能——自定义升星概率。玩家可以根据自己的喜好和策略,为不同的武器设置不同的成功率和降级率。比如,你可以将“嗜血”这把武器的升星难度设置得极高,以体现其稀有性和强大威力;也可以将“平底锅”这样的普通武器设置得相对容易升星,让玩家在升级过程中感受到更多的成就感。这种自定义的概率设置,不仅增加了游戏的趣味性和挑战性,还让玩家在升级过程中有了更多的策略和选择。你可以根据自己的武器库和卷轴数量,制定出最合适的升级计划,从而在游戏中占据先机。

nmdbbzcl的博客 1265

HDOJ_1050 Moving Tables 解题报告

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 sid

xxm137164869的专栏 2024

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

POJ1083 Moving Tables

POJ1083 Moving Tables Time Limit:1000MS Memory Limit:10000K Total Submissions:35297 Accepted:11774 Description The famous ACM (Advanced Computer Maker) Company has ...

weixin_30760895的博客 156

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

1050 Moving Tables 贪心算法

Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 12304    Accepted Submission(s): 4226 Problem Description The famous

Jolesen的博客 715

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

POJ 1083 Moving Tables

POJ 1083 Moving Tables 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 sout...

不屈不挠的拉普 288

hdu-1050 Moving Tables

hdu-1050 Moving Tables 题目链接 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...

bayleexu 352

hdoj.1050 Moving Tables 20140811

Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19258    Accepted Submission(s): 6579 Problem Description The famous AC

>>--» 唯n1.情缘«--<< 286

POJ 1083 Moving Tables 已被翻译

woniupengpeng的专栏 383

zoj1029 Moving Tables

//zoj1029 Moving Tables //Accepted 1029 C++ 00:00.01 436K #include #include #include using namespac

fairylan的专栏 945

HDOJ 1050 Moving Tables 【贪心】

HDOJ 1050 Moving Tables 【贪心】 题目链接 acm.hdu.edu.cn/showproblem.php?pid=1050 这个题是根据贪心训练所以写的贪心 但是有一种更简单的求法就是求最大重复区间: 【将走廊分成200块,每次输入后就对涉及到的走廊+1 最后输出这些数组里最大的数*10就可以了】 上面这种写法比较简单,不贴代码了 贪心的话首先

... 343

杭电 1150 moving tables

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

weixin_34067102的博客 102

HDU-1050-Moving Tables(C++ && 贪心初步)

Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23147    Accepted Submission(s): 7779 Problem Description The famous

保持对编程的热情! 1657

Moving tables

Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 36594    Accepted Submission(s): 12040 Problem Description The famous

穆梓先生 1397
上一篇: Elevator
下一篇: 希尔排序
Ethan_YS
博客等级 码龄10年 3粉丝 7原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值