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 微信支付之微信模板消息推送
微信支付之微信模板消息推送 今天我要跟大家分享的是“模板消息”的推送,这玩意呢,你说用途嘛,那还是真真的牛逼呐.原因在哪?就是因为它是依赖微信生存的呀,所以他能不 ...
随机推荐
- static 和 no static Member function学习
以下是做实验的一段代码: #include <iostream> using namespace std; typedef void (*p)(); class Object { publ ...
- Fiddler Session标志
Each Session object in Fiddler contains a collection of string flags, in the Session.oFlags[] collec ...
- 建立与读取.ini文件
一般读写ini文件被读写Registry所取代,但我们还是可以透过 win31的传统方式读写ini文件,以存程式目前的相关设定,而於下一次程式执行时再 读回来.目前建议使用GetSetting Sav ...
- MySQL 数据库几种类型
关系数据库(MySQL.Oracle.SQL Server.DB2.Postgres)键-值存储数据库(Riak和Redis)面向列的数据库(HBase) 面向文档的数据库(MongoDB 和Couc ...
- vue源码cached高阶函数解析
1.源代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...
- 【转】javascript中值传递,地址传递,引用传递的问题(使用js创建list对象时会用到)
function initEditModal_SI(node) { if (node.siArray == undefined) { node.siArray = new Object(); } va ...
- centos 6.4 调整home和root分区大小
调整过程中可以随时查看硬盘分区情况,命令: lsblk df -h 压缩home分区到5G: [root@fscp-dev /]# df -h 文件系统 容量 已用 可用 已用%% 挂载点 /dev/ ...
- Log4net的配置-按照日期+文件大小混合分割
ender name="DebugAppender" type="log4net.Appender.RollingFileAppender"><fi ...
- Linux ssh服务开启秘钥和密码认证
问题描述: 实现Linux秘钥和密码同时认证 解决方案: vim /etc/ssh/sshd_config 基本参数: PermitRootLogin yes #允许root认证登录 Password ...
- Androidmanifest.xml在Android项目中的作用
以下是一个项目中的AndroidManifest.xml文件: <?xml version="1.0" encoding="utf-8"?> < ...