POJ 1083 Moving Tables

POJ1083-Moving Tables 北大POJ1083-Moving Tables 解题报告+AC代码 立即下载

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 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 3 + N -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

题意描述:

给出n对房间号,然后让你从第一个房间里边移动一张桌子,移到第二个房间里边,无论多远10分钟之内都可以完成,但是走廊每次只能移动一张,问n对全不完成,需要多长时间。

解题思路:

由题的图一可以看出来,它是单号一边双号一边,因此需要判断初始和结束房间的单双号,(假设从2号移到5号,因为2号在移动的时候1号也被占用,同理移到5号时6号也被占用了。)用一个数组标记之后找出最大的层数10就可以了。

AC代码:

#include<stdio.h>
#include<string.h>
int main(void)
{
	int t,n,count,s,t1,book[410],max,z,temp;
	scanf("%d",&t);
	while(t--){
		count=1;
		z=-1;max=-1;
		memset(book,0,sizeof(book));
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d%d",&s,&t1);
			if(s>t1){
				temp=s;
				s=t1;
				t1=temp;
			}
			if(s%2==0)
				s--;
			if(t1%2!=0)
				t1++;
			for(int j=s;j<=t1;j++)
				book[j]++;
		}
		for(int k=1;k<=400;k++)
			if(max<book[k])
				max=book[k];
		printf("%d\n",max*10);	
	}
	return 0;
}
acm程序例题2道,还有一道思考的题目(第四题) 这个是对于一道acm程序设计中的一道题,同时在解题同时还引出了第四题 立即下载

相关推荐

VLA强化学习训练:π0到π0.5的技术优化与实现

视觉语言动作模型(VLA)作为多模态强化学习的重要分支,通过融合视觉、语言和环境状态数据实现智能决策。其核心技术在于多模态特征融合与动作空间设计,其中PPO算法因其出色的训练稳定性成为首选方案。在工程实践中,延迟补偿机制和课程学习设计能显著提升模型性能,如在四足机器人项目中使避障成功率提升47%。针对实际部署中的性能下降问题,需要特别关注硬件量化参数和控制频率一致性等关键因素。本文通过π0与π0.5版本的对比实验,详细解析了VLA模型在机械臂控制等具身智能场景中的优化路径。

weixin_29041767的博客 246

搬桌子问题

The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. r has 200 rooms each on the north side and south side along the corridor. Rece...

qq_43628925的博客 1064

【Linux系统】Kdenlive软件多机位同音频视频同步化处理

Kdenlive简介 官网链接:https://kdenlive.org/zh/ 命令行安装: apt-get install kdenlive Kdenlive能够进行多轨道视频编辑,可以使用和调整多条音频、视频轨道。每条轨道可以按需进行单独锁定、静音。 Kdenlive多机位同音频视频同步化处理步骤 1. 新建Kdenlive文件 选择<文件>-<新建>,建立新的kdenlive文件,初始设置为<视频轨:2>,<音频轨:2>。 视.

qq_31550269的博客 1886

HDU1050 Moving Tables

  Moving TablesTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1715    Accepted Submission(s): 663Problem DescriptionThe famous ACM (Advan

Adam·Niuen 3130

光斑定位 - MATLAB实现

光斑定位是一种常见的图像处理任务,它涉及到在图像中准确定位光斑或亮点的位置。在本篇文章中,我们将使用MATLAB来实现光斑定位的算法,并提供相应的源代码。希望本文提供的MATLAB代码和步骤能够帮助您实现光斑定位任务。通过这些代码,您可以在MATLAB环境中轻松地定位光斑,并在图像上进行可视化展示。这样,我们就完成了光斑定位算法的MATLAB实现。通过以上步骤,我们可以得到一个在光斑位置上标记的图像,从而实现了光斑的准确定位。光斑定位 - MATLAB实现。

qq_39605374的博客 764

36、T5L 迪文屏C51开发之绘制动态曲线

T5L 迪文屏C51开发之绘制动态曲线1、介绍2、例程功能简介3、GUI界面设计3、C51程序设计 1、介绍   本文将利用DGUS Tool软件中的【动态曲线控件】来绘制曲线效果,在T5L迪文屏中总共支持8个通道的曲线,而曲线数据是需要缓冲区的,如果 8 通道曲线同时使用,0x1000-0x4FFF 将作为曲线缓冲区地址,此时该部分变量地址不能被其他控键使用,其他控键地址使用范围为0x5000-0xFFFF,当某曲线通道不被使用时,那么其所对应的缓冲区地址可以做其他用途,曲线通道具体的地址分布如下图所示:

嵌入式羊圈 3133

每周一题2_杭电ACM_Moving Tables

Moving Tables 题目来源:杭电ACM 1.3.1 原题描述 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

童话与梦的博客 691

AXI总线详解完结篇

经过几个月的整理和发文,AXI总线详解系列正式迎来最终篇,内容基本涵盖了上一篇文章的全部内容。 所有文章的链接如下: 1、 AXI总线详解 2、AXI总线详解-总线和接口以及协议 3、AXI协议中的通道结构 4、AXI总线详解-AXI4读写操作时序及AXI4猝发地址及选择 5、AXI4交换机制 6、ZYNQ中DMA与AXI4总线-DMA简介 7、AXI总线详解-不同类型的DMA 8、AXI总线详解-DMA内部寄存器的读写方式 9、AXI总线详解-几种应用DMA的场合 10、Altera Scatter-G.

OpenFPGA的博客 5493

HDU_1050 重叠数

先将数组进行排序,第一次循环,将不重叠的元素从数组中删除(这里将flag赋值为false),sum+=10继续第二次循环,以此类推,直到数组中没有元素(flag全为false)#include #include #include using namespace std; struct move{ public: int start; int end; bool flag; }; bool comp( move p, move q){ return p.s

格物致知 941

19 04-读取DTC快照信息

为了方便找到故障的原因,车厂一般会在诊断调查表中定义一些信息作为快照信息,例如故障发生时间、电压、行驶里程数、车速等。在对应故障发生时,ECU端要记录发生故障时的快照信息,客户端可以通过此服务检索客户端定义的DTCMaskRecord的捕获DTC Snapshot记录号以及DTCSnapshot记录数据。通过查找故障发生时刻的这些数据,来分析故障原因。

诊断协议那些事儿's blog 5146

C++程序发生内存越界,一定会导致程序崩溃吗?详解内存越界

内存越界是否一定会导致程序崩溃吗?详解内存越界

dvlinker的技术专栏 1万+

SDAU 贪心专题 00 搬桌子

1:问题描述Problem DescriptionThe 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

ww的博客 563

Autosar MCAL-S32k324 Crypto配置-基于EB

NXP官网提供了免费的HSE固件,同时也提供了对应的协议栈。本文以算法为例,介绍MCAL相关的配置及在代码中的集成与使用。使用HSE计算,比软件算法确实方便许多。后面会完善更多的算法测试。

赞的博客 2436

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

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

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

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

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

不屈不挠的拉普 287

假人有限元模型

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

POJ 1083 Moving Tables 已被翻译

woniupengpeng的专栏 380

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

POJ 刷题系列:1083. Moving Tables

POJ 刷题系列:1083. Moving Tables传送门:POJ 1083. Moving Tables题意: 一条走廊,两栏房间。搬运工每次从房价i移动到房间j需要10分钟,给定一系列的移动路线 i -> j,问最少需要多少时间。 思路: 实际上是求解多个区间中重叠区间的最大个数。采用imos累积,很好的一个思路。先对每个区间的起点和终点求偏导,然后再累积,累积数组中的最大值即

Demon-初来驾到 747

poj1083 Moving Tables

链接:http://poj.org/problem?id=1083 好早的一个题,大一的时候做过一次。当然没做出来。今天又拿出来做了。 discuss中很多说贪心过不了,但我还是看到有个别人用贪心过的。所以,我也是坚持要用贪心写。 有些个地方要注意: 1)s、t大小未知,所以必要时要对其进行交换 2)对房间号做处理: s=(s+1)/2; t=(t+1)/2; 3)对s进行排序(在

u012914220的专栏 1124

POJ 1083 Moving Tables 贪心

题目来源:http://poj.org/problem?id=1083 题意:就是在房间之间移动桌子,当移动两个桌子时,这两个房间之间的走廊是满的,即其他的移动不能占用该段空间。求最少移动时间。 思路:按左端点排序,之后两重循环即可。需要注意的地方,左端点不一定比右端点大,因此需要处理一下。 代码: #include #include #include #include using

1081

【poj刷题记录】1083:Moving Tables

培养信心练手题,POJ1083题目描述如下: 这题的思路就是把房号转化为走廊编号(偶数房号除以2得到对应走廊编号,奇数房号加一除以二的打斗对应走廊编号),然后对个编号的走廊被走过的次数进行统计,整条走廊中走过次数最高的一段的次数即为最少搬运趟数。需要注意的是这道题的输入房号可能是先大后小,需要处理一下,不然就会陷入绝望WA中ORZ(别问我为什么知道),具体代码如下: #include <...

qq_38331950的博客 382

POJ - 1083 Moving Tables

//poj 1083 // [6/11/2014 wind] #include #include #include #include using namespace std; const int MAX_N = 200; int n; int cdr1[MAX_N], cdr2[MAX_N]; int cnt[MAX_N]; void solve() { memset ( cnt,

NightWind 734

POJ1083 Moving Tables(思维详解)

POJ 1083http://poj.org/problem?id=1083 题目大意: 题目很长,大致意思是有400个面对面的房间,现在要从一个房间到另一个房间移动物品 ,每次花费10分钟,但是移动过程中所有的经过的走廊都会被占用,也就是不能使用,问最少移动完所有的物品需要多久。 解题思路: 由于每次移动过程中都会占用相关的走廊,因此我们只需要枚举每个房间前的走廊需要被...

Sensente的博客 472

POJ 1083 Moving Tables 题解

POJ 1083题解

DarkoDu的博客 733

poj 1083 Moving Tables

模拟题,用到了编程之美中的思想---高效率地安排见面会 其实这个搬桌子是一样的,占用过道,那么核心思想就是把过道看成那个题目里面的时间轴 那么思想就是找到这个时间轴上的某一个时间点,使包括这个时间点的时间区间个数最多,那么这个个数乘以十就是我们要求的搬桌子的时间 代码的核心思想: 把所有的B[i],E[i]按大小排序,然后遍历这个统一的数组,如果遇到一个B[i],就把当前的时间数加

qwerty_xk的专栏 1549
上一篇: POJ 3641 Pseudoprime numbers
下一篇: POJ 3050 Hopscotch(dfs暴力)
鳳九~
博客等级 码龄8年 1384粉丝 215原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值