推桌子

时间限制:1000 ms  |  内存限制:65535 KB
难度:3
描述
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 推桌子的更多相关文章

  1. nyoj220 推桌子(贪心算法)

    这道题太坑了,from 和to有可能写反,还得正过来: 推桌子 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 The famous ACM (Advanced Co ...

  2. ACM 推桌子

    推桌子 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 The famous ACM (Advanced Computer Maker) Company has re ...

  3. nyist 220 推桌子

    题目链接:推桌子 题目意思:给你一些操作,将S出的桌子推到L出,但是这个过道有时会被占用,推一次是10min,不影响的操作可以同时开始,并且只记一次. 思路:贪心,首先按照S从小到大排序,决策:从第一 ...

  4. nyoj 220——推桌子——————【贪心】

    推桌子 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 The famous ACM (Advanced Computer Maker) Company has re ...

  5. 在Openfire上弄一个简单的推送系统

    推送系统 说是推送系统有点大,其实就是一个消息广播功能吧.作用其实也就是由服务端接收到消息然后推送到订阅的客户端. 思路 对于推送最关键的是服务端向客户端发送数据,客户端向服务端订阅自己想要的消息.这 ...

  6. iOS---iOS10适配iOS当前所有系统的远程推送

    一.iOS推送通知简介 众所周知苹果的推送通知从iOS3开始出现, 每一年都会更新一些新的用法. 譬如iOS7出现的Silent remote notifications(远程静默推送), iOS8出 ...

  7. SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=》提升)

     SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=>提升,5个Demo贯彻全篇,感兴趣的玩才是真的学) 官方demo:http://www.asp.net/si ...

  8. SignalR SelfHost实时消息,集成到web中,实现服务器消息推送

    先前用过两次SignalR,但是中途有段时间没弄了,今天重新弄,发现已经忘得差不多了,做个笔记! 首先创建一个控制台项目Nuget添加引用联机搜索:Microsoft.AspNet.SignalR.S ...

  9. 【原创分享·微信支付】C# MVC 微信支付之微信模板消息推送

    微信支付之微信模板消息推送                    今天我要跟大家分享的是“模板消息”的推送,这玩意呢,你说用途嘛,那还是真真的牛逼呐.原因在哪?就是因为它是依赖微信生存的呀,所以他能不 ...

随机推荐

  1. VIM显示utf-8文档乱码解决方法

    1.相关基础知识介绍 在Vim中.有四个与编码有关的选项,它们是:fileencodings.fileencoding.encoding和termencoding. 在实际使用中.不论什么一个选项出现 ...

  2. java经典小程序

    1,编写程序,判断给定的某个年份是否是闰年. 闰年的判断规则如下: (1)若某个年份能被4整除但不能被100整除,则是闰年. (2)若某个年份能被400整除,则也是闰年. import java.ut ...

  3. Android——SD卡工具类——SDCardUtils.java

    package com.xdsjs.save.utils; /** * SD卡相关的辅助类 * Created by xdsjs on 2015/10/13. */ import java.io.Fi ...

  4. Codevs3008 加工生产调度

    题目大意:某工厂收到了n个产品的订单,这n个产品分别在A.B两个车间加工,而且必须先在A车间加工后才干够到B车间加工. 求如何安排这n个产品的加工顺序.才干使总的加工时间最短. 这里所说的加工时间是指 ...

  5. WebApi 数据保护操作未成功。这可能是由于未为当前线程的用户上下文加载用户配置文件导致的。当线程执行模拟时,可能会出现此情况。","ExceptionType":"System.Security.Cryptography.CryptographicException","StackTrace

    在调用System.Security.Cryptography.ProtectedData.Protect方法来保护私密信息时,IIS可能会报以下错误:CryptographicException: ...

  6. linux YUM常用 命令

    语法 yum(选项)(参数) 选项 -h:显示帮助信息: -y:对所有的提问都回答“yes”: -c:指定配置文件: -q:安静模式: -v:详细模式: -d:设置调试等级(0-10): -e:设置错 ...

  7. 学习KNN

    转:© 著作权归作者所有 by ido 什么是KNN算法呢?顾名思义,就是K-Nearest neighbors Algorithms的简称.我们可能都知道最近邻算法,它就是KNN算法在k=1时的特例 ...

  8. HighCharts/Highstock使用小结,使用汉化及中文帮助文档

       此文档是本人在开发过程图形报表时使用HighCharts所遇到的问题及解决方案 .最后附上有HighCharts中文帮助文档 HighCharts  版本:Highcharts-3.0.1 Hi ...

  9. JavaScript的技巧和最佳实践

    JavaScript是一个绝冠全球的编程语言,可用于Web开发.移动应用开发(PhoneGap.Appcelerator).服务器端开发 (Node.js和Wakanda)等等.JavaScript还 ...

  10. jquerymobile 的特有 事件 和 方法 (转)

    1.触摸屏事件—— Touch events tap Triggers after a quick, complete touch event. 本人实际测试效果:轻轻点击,效果和按普通按钮差不多. ...