hdoj 1050 Moving Tables

白炽灯寿命工程解析:从钨丝蒸发到电压控制的可靠性设计 白炽灯作为一种经典的电光源,其工作原理基于电流通过钨丝产生热辐射发光。在高温下,钨丝会持续蒸发导致灯丝逐渐变细、电阻增大,这是影响其寿命的核心物理机制。从工程角度看,白炽灯的可靠性设计涉及材料科学、热力学和电路设计的交叉,技术价值在于通过理解其失效原理,可以在成本与性能间取得最佳平衡。在实际应用中,电压波动、开关浪涌电流和机械振动是主要寿命杀手,尤其在工业控制、仪器仪表和特定照明场景中,合理的设计能大幅提升系统稳定性。本文深入探讨了钨蒸发、热应力等关键因素,并结合浪涌抑制和降压设计等实战技巧,为工程师提供了 阅读详情

Moving Tables

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 24631    Accepted Submission(s): 8144


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
 
思路:两个房间之间交换桌子,由于走廊窄,桌子大,走廊只能通过一张桌子,不会出现并排的桌子,问最少需要多长时间能把要求移动的桌子移动完。最少时间对应走廊共享(也可以理解为交叉)次数最多的那一段所用的时间。贪心,求最大重叠区间。别忘了判断前后两个房间的大小。因为房间是两侧的,所以要注意房间的奇偶性。
 
代码:
 
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int cmp(int a,int b)
{
	return a>b;
}
int main()
{
	int T,n,i,j,s,t,temp;
	int a[1000];
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		memset(a,0,sizeof(a));
		for(i=1;i<=n;i++)
		{
			scanf("%d%d",&s,&t);
			if(s>t)
			{
				temp=s;
				s=t;
				t=temp;
			}
			s=(s+1)/2;
			t=(t+1)/2;
			for(j=s;j<=t;j++)
			{
				a[j]++;
			}
		}
		sort(a,a+1000,cmp);
		printf("%d\n",a[0]*10);
	}
	return 0;
}

用 Joule 点燃 ABAP 开发者的舞台感:SAP BTP 上的 ABAP AI 能力实战解读 摘要:SAP推出的Joule for developers和ABAP AI功能为开发者提供了智能辅助工具,旨在优化ABAP开发流程。主要功能包括上下文感知的代码预测补全、代码解释、单元测试生成和开发问题实时解答。这些能力特别适合应对Cloud环境下ABAP开发的复杂约束,如Clean Core原则和受限语法范围。通过减少重复劳动和提升代码理解效率,该工具帮助开发者将注意力集中在业务逻辑而非技术细节上。随着企业加速向S/4HANA迁移,这些AI功能将在遗留代码改造和云适配中发挥更大作用,建议团队将其纳入工程体 阅读详情

相关推荐

开关电源EMI整改:RC吸收电路参数优化,实测传导骚扰降低10dB(附PCB布局要点)

本文详细解析了开关电源EMI整改中RC吸收电路的参数优化方法,通过实测数据展示如何降低传导骚扰10dB以上。从电容选择、电阻计算到PCB布局的黄金法则,提供了一套完整的解决方案,特别适用于30-100MHz高频段的EMI问题。文章还包含反激电源和Buck电路的具体整改案例,帮助工程师快速解决实际应用中的传导骚扰超标问题。

weixin_34194829的博客 256

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

体验灵雀云-创建基于Docker的云服务

今天体验了一下灵雀云,创建了第一个基于Docker的云服务。 1.登录灵雀云 2.开始使用 登录之后,从"控制台"进入操作界面,开始创建服务。 首先需要选择一个镜像。灵雀云已经为您提供了一些常用的镜像列表。请在“常用镜像”列表中,选择“其它”,然后找到“alauda/hello-world”镜像,点击它右侧的“选择”按钮,进入服务参数配置页面。 选择完要创建的

tomcat的专栏 3240

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

因果推断综述-A Survey on Causal Inference

最近读到一篇讲述很全面的综述文献-《A Survey on Causal Inference》,对于接触因果推断不久的同学而言是特别详细的介绍和科普。文献很长,我会分成几部分介绍。 目录 摘要 第一部分:简介 第二部分:因果推断基础知识 第三部分:基于三种假设的因果推断方法 第四部分:实验 第五部分:应用 摘要 几十年来,因果推理是一个跨许多领域的关键研究主题,如统计、计算机科学、教育、公共政策和经济学。与随机对照试验相比,研究方向由于可用数据量大且预算要求低,如今,从观测数据..

海边凝望的博客 3189

手机拍照对焦快准狠的秘密:一文看懂PDAF、Dual Pixel和Super PD的区别

本文深入解析手机拍照中的三种主流相位检测自动对焦(PDAF)技术:Shield Pixel、Super PD和Dual Pixel。通过对比它们的原理、优缺点及实际表现,帮助读者理解不同技术的对焦速度、暗光表现和画质影响,从而做出更明智的购机选择。

weixin_26985923的博客 496

HDOJ 1050 Moving Tables 【贪心】

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

... 343

鸿蒙OpenHarmony技术:【Docker编译环境】

OpenHarmony为开发者提供了两种Docker环境,以帮助开发者快速完成复杂的开发环境准备工作。独立Docker环境:适用于直接基于Ubuntu、Windows操作系统平台进行版本编译的场景。基于HPM的Docker环境:适用于使用HPM工具进行发行版编译的场景。点击或者复制转到。表1Docker镜像介绍系统类型运行平台Docker镜像仓库标签标准系统(独立Docker环境)3.2小型系统(独立Docker环境)3.2轻量系统(独立Docker环境)3.2。

m0_62167422的博客 1447

ACM--移动桌子--贪心--HDOJ 1050--Moving Tables

HDOJ题目地址:传送门 Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 28729    Accepted Submission(s): 9435 Problem De

戎码人生 1万+

梯度提升决策树GBDT原理与代码实例讲解

梯度提升决策树GBDT原理与代码实例讲解 1.背景介绍 1.1 机器学习发展历程 机器学习是人工智能领域的一个重要分支,旨在使计算机具备学习和改进自身性能的能力。随着大数据时代的到来,海量的数据为机器学习算法提供了广阔的应用空间。在

AI天才研究院 1093

WPF vs Avalonia: 跨入C#桌面应用现代化的大门

请注意,这只是一个目录,详细内容将根据这个结构逐步展开。如果您需要某个特定部分的详细内容,请告知我,我将为您提供深入的解析和示例代码。WPF,全称Windows Presentation Foundation,是微软为Windows平台量身打造的UI框架。自2006年发布以来,它就像一位经验丰富的老船长,引领着桌面应用的航船在技术的海洋中乘风破浪。Avalonia,一个新兴的跨平台UI框架,它像一位年轻的探险家,勇敢地探索着桌面应用的新世界。

java专栏 2404

【HDOJ】1050 moving tables

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

Coyilla的博客 343

QGIS编译(跨平台编译)001:Flex、Bison编译(安装)(Windows、Linux、MacOS环境下安装)

QGIS编译;Flex、Bison编译(安装)(Windows、Linux、MacOS环境下安装)

LuckyHanMo的博客 3091

HDOJ1050 Moving Tables

原题链接 #include struct Node{ int begin, end; }; Node a[201]; int p[401]; int main(){ int t, n, i, temp, count, j; scanf("%d", &t); while(t--){ scanf("%d", &n); for(i = 0; i != n; ++i){

长风的专栏 758

pscad IEEE标准系统搭建说明

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

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

HDOJ 1050 Moving Tables

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

RaAlGhul的博客 439

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

【hdoj_1050】Moving Tables

题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1050 题意为: 为了叙述方便,把一个房间里面的桌子移动到另一个房间称为一个移动,给出若干个要求完成的移动,任意两个移动仅在移动路线不相交的情况下可以同时进行,求出移动所需花费的最小次数(时间). 注意: 出现有"对门"的路线,不能同时移动,例如,[2,4]和[3,5]不能同时进行,因

tensory的博客 319

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

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 side and s...

CSDN2082的博客 446

HDOJ Moving Tables JAVA 1050

贪心算法 对于这个题,一开始走的是模拟的思想,建立了相应的类进行模拟,不仅慢,复杂,而且结果wrong(不知道为什么) 后来改进了思想才轻松AC的: 主要是看每个房间出现过几次。因为一个房间每次只能出现一次,所以出现的最多的次数就是答案。 package _1050; import java.util.Arrays; import java.util.Scanner; publ

董公子的博客 440

HDOJ 1050 Moving Tables

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

MADE_Y 343

HDOJ--1050Moving Tables!!

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 ea

y_Cnew的博客 494

HDOJ 1050 :Moving tables

题目大意 著名的ACM(高级计算机制造商)公司租用了一栋建筑的地板,其形状如下。楼沿走廊的北侧和南侧各有200间客房。最近,公司制定了一项改革计划。改革包括在房间之间移动很多桌子。因为走廊很窄,所有的桌子都很大,只有一张桌子能穿过走廊。需要一些计划来提高移动效率。经理想出了以下计划:将桌子从房间移到另一个房间可以在 10 分钟内完成。将桌子从 I 房间移到 j 房间时,使用 I 房间前面和 j 房间前面之间的走廊部分。因此,每10分钟,在两个房间之间移动几个不共享走廊的同一部分将同时进行。为了清楚说明,经

m0_61223040的博客 309

HDOJ HDU 1050 Moving Tables

HDOJ 1050 Moving Tables题目 点此查看 HDOJ 1050 Moving Tables 分类 贪心 题意 搬桌子 有南北各里200间房,和中间走廊 如图 每次从 房间s 搬到 房间t 走廊每次只能过一张桌子 每次搬运耗时 10min 求 最短时间 例如 : 11 搬到 12 ,14 搬到

Gy_1096440940的博客 334

hdoj 1050 Moving Tables

从教程上看到是用贪心的思想求解, 但是自己途中还不求错了。 原因是两排,每两个房间只对应一个过道。然后我们对过道计数即可。 贪心的想法就是每次我选重叠最多的过道进行搬。#include #include #include #include #include #include #include #include #include #include #include #include #inclu

东篱南山下的七柳先森丶 696

HDOJ 1050 Moving Tables(贪心&&灵活)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050 题目大意:从房间i移到到房间j,在移动过程中,走廊i-j这一个部分被占用。只要不共用走廊的移动都可同时进行,每移动一次需要10分钟。 题目分析: 1.注意房间构造,奇数房间在上面,偶数房间在下面,但是相对的房间占用同一个走廊。所以我们把房间都转换为同一边。 room=(room+1)/...

Syy 224
上一篇: hdoj 1130 How Many Trees? 【卡特兰数】
下一篇: hdoj 4786 Fibonacci Tree 【最小生成树&&最大生成树】
l踏雪无痕ll
博客等级 码龄12年 28粉丝 259原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值