推桌子

时间限制: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. 使用ADS1.2的注意事项及常用技巧

    如果创建的项目中有多个文件时(尤其是编译后的镜像大小超过4K时),一定要在link order栏下调整文件顺序,主要是前几个文件的顺序(2440init.s.2440slib.s.nand.c这三个文 ...

  2. python解析发往本机的数据包示例 (解析数据包)

    tcp.py # -*- coding: cp936 -*- import socket from struct import * from time import ctime,sleep from ...

  3. SVN如何查看修改的文件记录

    主要是有四个命令,svn log用来展示svn 的版本作者.日期.路径等等:svn diff,用来显示特定修改的行级详细信息:svn cat,取得在特定版本的某文件显示在当前屏幕:svn  list, ...

  4. 简单的Stack

    自己实现的简单的Stack.没有查空满.用于算法考试 #include<iostream> using namespace std; const int MAX = 100; struct ...

  5. webservice系统学习笔记5-手动构建/发送/解析SOAP消息

    手动拼接SOAP消息调用webservice SOAP消息的组成: 1.创建需要发送的SOAP消息的XML(add方法为例子) /** * 创建访问add方法的SOAP消息的xml */ @Test ...

  6. 在shell中使用sed命令替换/为\/

    sed命令相关: https://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html https://www.cnblogs.com/D ...

  7. Ajax Control Toolkit 34个服务器端控件的使用

    摘自:http://blog.csdn.net/yaoshuyun/article/details/2218633 1. Accordion[功能概述] Accordion可以让你设计多个panel  ...

  8. LinkedHashMap插入无序且链式操作

    Iterator<Entry<Integer, Integer>> ite=lhmap.entrySet().iterator(); ite.next(); ite.remov ...

  9. HDUOJ---1862EXCEL排序

    EXCEL排序 Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  10. POJ 3295 Tautology (构造法)

    Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7716   Accepted: 2935 Descrip ...