ny220 推桌子
推桌子
- 描述
- 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.- 输入
- 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. - 输出
- 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
解题分析:其实和房间安排很像的一个题,只不过需要把房间安排门号,转移到走廊上;#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int n,t,ss[];
int a,b,c,m;
cin>>t;
while(t--)
{
int max=;
memset(ss,,sizeof(ss));
cin>>n;
for(int i=;i<n;i++)
{
cin>>b>>c;
if(b>c){m=b;b=c;c=m;}//出来的大小会不同的,调整一下顺序
c=(c+)/;//转移到走廊上
b=(b+)/;
for(int j=b;j<=c;j++)
{
ss[j]++;
if(ss[j]>max)
max=ss[j];
}
}
cout<<max*<<endl;
}
return ;
}
ny220 推桌子的更多相关文章
- nyoj220 推桌子(贪心算法)
这道题太坑了,from 和to有可能写反,还得正过来: 推桌子 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 The famous ACM (Advanced Co ...
- ACM 推桌子
推桌子 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 The famous ACM (Advanced Computer Maker) Company has re ...
- nyist 220 推桌子
题目链接:推桌子 题目意思:给你一些操作,将S出的桌子推到L出,但是这个过道有时会被占用,推一次是10min,不影响的操作可以同时开始,并且只记一次. 思路:贪心,首先按照S从小到大排序,决策:从第一 ...
- nyoj 220——推桌子——————【贪心】
推桌子 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 The famous ACM (Advanced Computer Maker) Company has re ...
- 在Openfire上弄一个简单的推送系统
推送系统 说是推送系统有点大,其实就是一个消息广播功能吧.作用其实也就是由服务端接收到消息然后推送到订阅的客户端. 思路 对于推送最关键的是服务端向客户端发送数据,客户端向服务端订阅自己想要的消息.这 ...
- iOS---iOS10适配iOS当前所有系统的远程推送
一.iOS推送通知简介 众所周知苹果的推送通知从iOS3开始出现, 每一年都会更新一些新的用法. 譬如iOS7出现的Silent remote notifications(远程静默推送), iOS8出 ...
- SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=》提升)
SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=>提升,5个Demo贯彻全篇,感兴趣的玩才是真的学) 官方demo:http://www.asp.net/si ...
- SignalR SelfHost实时消息,集成到web中,实现服务器消息推送
先前用过两次SignalR,但是中途有段时间没弄了,今天重新弄,发现已经忘得差不多了,做个笔记! 首先创建一个控制台项目Nuget添加引用联机搜索:Microsoft.AspNet.SignalR.S ...
- 【原创分享·微信支付】C# MVC 微信支付之微信模板消息推送
微信支付之微信模板消息推送 今天我要跟大家分享的是“模板消息”的推送,这玩意呢,你说用途嘛,那还是真真的牛逼呐.原因在哪?就是因为它是依赖微信生存的呀,所以他能不 ...
随机推荐
- shell中如何取括号中的字符
1. 使用grep(结果带括号,不知道有没有办法仅把括号中的内容匹配出来) $a='abc[edg]adfirpqu' $echo $a|grep -o '\[.*\]' #中括号的处理需要转义 [e ...
- UVa 10642 - Can You Solve It?
题目:二维平面上的整数点.用路径链接起来(0,0)->(1.0)->(0.1)->(2,0)->.. 给你两点坐标.求两点间步长(在路径上的距离). 分析:简单题. 我们发现点 ...
- Swift教程_swift常见问题(0005)_完美解决Cannot override 'dealloc'异常
Swift教程_swift常见问题(0001)_CoreData: warning: Unable to load class named 'xxx' for entity 'xxx' Swift教程 ...
- ActiveMQ基本介绍
1.ActiveMQ服务器工作模型 通过ActiveMQ消息服务交换消息.消息生产者将消息发送至消息服务,消息消费者则从消息服务接收这些消息.这些消息传送操作是使用一组实现 ActiveM ...
- [Done]SnowFlake 分布式环境下基于ZK构WorkId
Twitter 的 Snowflake 大家应该都熟悉的,先上个图: 时间戳 序列号一般不会去改造,主要是工作机器id,大家会进行相关改造,我厂对工作机器进行了如下改造(估计大家都差不多吧,囧~~~ ...
- HTTP协议详解之请求篇
•HTTP请求由3部分组成:请求行.消息报头.请求正文. 1)请求行以一个方法符号开头,以空格分开,后面跟随请求的URI和协议的版本,格式:Method Request-URI HTTP-Versio ...
- CentOS 7 网络磁盘挂载到本地 并测试传输速度
本文中的配置只做测试使用,正式环境中考虑到安全,请自行结合网上介绍的配置细节完善配置内容. 首先明确两个概念,服务器和客户端(本地),我们要做的是将服务端的硬盘上的/home/liuyx 目录挂载到本 ...
- 深入PHP内核之参数
1.看一下一个扩展中的简单代码 ZEND_BEGIN_ARG_INFO(params_add_arginfo, 0) ZEND_ARG_INFO(0, a) ZEND_ARG_INFO(0, b) Z ...
- java.lang.UnsupportedClassVersionError: org/hibernate/SessionFactory : Unsupported major.minor version 52.0
问题: 在学习hibernate的过程中,涉及导入jar包的问题,写该文的时候是从官网下载的最新的hibernate的jar包hibernate-release-5.2.10.Final .在测试时, ...
- HDUOJ---The Moving Points
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...