POJ_1083_(思维)
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 31511 | Accepted: 10528 |
Description

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
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
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
在dp题集里找到的这道题,收到别人分类的影响,却没能想到最简单的方法。。。以后做题要冷静分析。 只需统计每个过道被使用的次数,找最大值即可。勉强算个思维题吧。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 205 int way[];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
memset(way,,sizeof(way));
int n;
scanf("%d",&n);
int l=,r=;
for(int i=; i<=n; i++)
{
int a,b;
scanf("%d%d",&a,&b);
if(a>b)
{
int t=a;
a=b;
b=t;
}
int p=a;
do
{
if(p%)
way[p/+]+=;
else
way[p/]+=;
p+=;
}while(p<=b);
if(a%==&&p-<b)
way[p/]+=;
}
int res=;
for(int i=; i<=; i++)
if(way[i]>res)
res=way[i];
printf("%d\n",res);
}
return ;
}
POJ_1083_(思维)的更多相关文章
- [C#][算法] 用菜鸟的思维学习算法 -- 马桶排序、冒泡排序和快速排序
用菜鸟的思维学习算法 -- 马桶排序.冒泡排序和快速排序 [博主]反骨仔 [来源]http://www.cnblogs.com/liqingwen/p/4994261.html 目录 马桶排序(令人 ...
- Photoshop、Illustrator思维导图笔记
半年前学习Photoshop时记得的思维导图笔记,可能不是很全,常用的基本都记下了.
- CYQ.Data 从入门到放弃ORM系列:开篇:自动化框架编程思维
前言: 随着CYQ.Data 开始回归免费使用之后,发现用户的情绪越来越激动,为了保持这持续的激动性,让我有了开源的念头. 同时,由于框架经过这5-6年来的不断演进,以前发的早期教程已经太落后了,包括 ...
- 计算机程序的思维逻辑 (8) - char的真正含义
看似简单的char 通过前两节,我们应该对字符和文本的编码和乱码有了一个清晰的认识,但前两节都是与编程语言无关的,我们还是不知道怎么在程序中处理字符和文本. 本节讨论在Java中进行字符处理的基础 - ...
- 计算机程序的思维逻辑 (29) - 剖析String
上节介绍了单个字符的封装类Character,本节介绍字符串类.字符串操作大概是计算机程序中最常见的操作了,Java中表示字符串的类是String,本节就来详细介绍String. 字符串的基本使用是比 ...
- 计算机程序的思维逻辑 (31) - 剖析Arrays
数组是存储多个同类型元素的基本数据结构,数组中的元素在内存连续存放,可以通过数组下标直接定位任意元素,相比我们在后续章节介绍的其他容器,效率非常高. 数组操作是计算机程序中的常见基本操作,Java中有 ...
- 计算机程序的思维逻辑 (33) - Joda-Time
Joda-Time上节介绍了JDK API中的日期和时间类,我们提到了JDK API的一些不足,并提到,实践中有一个广泛使用的日期和时间类库,Joda-Time,本节我们就来介绍Joda-Time.俗 ...
- 计算机程序的思维逻辑 (53) - 剖析Collections - 算法
之前几节介绍了各种具体容器类和抽象容器类,上节我们提到,Java中有一个类Collections,提供了很多针对容器接口的通用功能,这些功能都是以静态方法的方式提供的. 都有哪些功能呢?大概可以分为两 ...
- 成吨提高开发效率:Intellij Shortcuts精简子集与思维模式
在线精简cheatsheet备查表:intellij.linesh.twGithub项目:intellij-mac-frequent-keymap Intellij的快捷键多而繁杂,从官方推荐的key ...
随机推荐
- imx6q GPIO功能的用法
假如我们要使用扩展口的第11脚EIM_D18. 先在arch/arm/plat-mxc/include/mach/iomux-mx6q.h中找有EIM_18. 能够找到MX6Q_PAD_EIM_D18 ...
- Oracle 远程访问配置 在 Windows Forms 和 WPF 应用中使用 FontAwesome 图标 C#反序列化XML异常:在 XML文档(0, 0)中有一个错误“缺少根元素” C#[Win32&WinCE&WM]应用程序只能运行一个实例:MutexHelper Decimal类型截取保留N位小数向上取, Decimal类型截取保留N位小数并且不进行四舍五入操作
Oracle 远程访问配置 服务端配置 如果不想自己写,可以通过 Net Manager 来配置. 以下配置文件中的 localhost 改为 ip 地址,否则,远程不能访问. 1.网络监听配置 ...
- 工作总结 2018-4-13 bootstrapTable 属性 queryParams: queryParams,//参数 get 中 %5B%5D 数组的意思
<table id="dataTable" data-toggle="table" data-show-columns="true" ...
- Lighttpd 插件mod_h264 streaming (mp4)安装
1. 对于安装lighttpd须要支持mp4伪流媒体格式,建议不要到官方下载lighttpd安装文件,到 插件H264 Streaming Module官网,下载已经整合了的安装包 http://h2 ...
- cojs 1001. [WZOI2011 S3] 消息传递
1001. [WZOI2011 S3] 消息传递 ★★ 输入文件:messagew.in 输出文件:messagew.out 简单对比时间限制:1 s 内存限制:128 MB Prob ...
- ios21--xib例子
故事板控制器: // // XMGViewController.m // 03-综合练习 // // Created by xiaomage on 15/12/28. // Copyright © 2 ...
- 洛谷 P1236 算24点
题目描述 几十年前全世界就流行一种数字游戏,至今仍有人乐此不疲.在中国我们把这种游戏称为"算24点".您作为游戏者将得到4个1~9之间的自然数作为操作数,而您的任务是对这4个操作数 ...
- bzoj4619
4619: [Wf2016]Swap Space Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 129 Solved: 54[Submit][Sta ...
- 【172】outlook邮箱设置
参考:outlook 2013设置 参考:Outlook设置hotmail邮箱POP3和SMTP服务器 注意
- 常用的八大排序算法,含java实例(copy)
说明:转载于http://www.cnblogs.com/qqzy168/archive/2013/08/03/3219201.html 分类: 1)插入排序(直接插入排序.希尔排序) 2)交换排序( ...