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 ...
随机推荐
- sqlite自己主动更新数据库
写一个类继承自 SQLiteOpenHelper 系统会自己主动加入构造方法. onCreate方法.onUpgrade方法 当数据库里面数据或者表结构有所修改时.咱们须要升级数据库 这个时候.版本 ...
- 32位win7系统下配置IIS遇到php-cgi.exe - FastCGI 进程意外退出问题的解决的方法
今天重装了一下系统,是32位的WIN7.装完系统后想把IIS装回来,由于有时候须要用到笔记本处理一些事情.结果WEBserver正常了.但IIS的FASTCGI模块始终不能解析PHP,一直报php-c ...
- ios打包静态库
1. 什么是库? 所谓库就是程序代码的集合,是共享程序代码的一种方式. 2. 库的分类 根据程序代码的开源情况,库可以分为两类 开源库源代码是公开的,你可以看到具体实现.比如GitHub上比较出名的第 ...
- 每天记录一点:NetCore获得配置文件 appsettings.json vue-router页面传值及接收值 详解webpack + vue + node 打造单页面(入门篇) 30分钟手把手教你学webpack实战 vue.js+webpack模块管理及组件开发
每天记录一点:NetCore获得配置文件 appsettings.json 用NetCore做项目如果用EF ORM在网上有很多的配置连接字符串,读取以及使用方法 由于很多朋友用的其他ORM如S ...
- Android 跑马灯效果与EditText冲突
近期一个项目,因为布局TextView内容太长了.首先想到的就是跑马灯效果,所以就把TextView又一次自己定义了,尽管跑马灯效果实现了.只是导致了还有一个问题就是EditText输入问题,当第一次 ...
- MySQL-插入数据(INSERT)
Insert语句可将一行或多行插入到表中. INSERT语法: INSERT INTO table(column1,column2...) VALUES (value1,value2,...); 首先 ...
- 2016/1/21 练习 arraylist 1,添加 add() 2,遍历集合
package shuzu; public class Customer { //从源码中 使用字段生成构造函数 public Customer(String good, int price) { s ...
- 使用Hibernate防止SQL注入的方法
之前写代码,往后台传入一个组织好的String类型的Hql或者Sql语句,去执行. 这样其实是很蠢的一种做法!!!! 举个栗子~~ 我们模仿一下用户登录的场景: 常见的做法是将前台获取到的用户名和密码 ...
- HNOI模拟 Day3.23
一.拓扑(top)[ 题目描述]:给你一个有向二分图,求他的拓扑序列的个数.[ 输入]:第一行两个数 N,M,表示点数和边数.接下来 M 行每行两个数 a,b,表示 a 向 b 有一条有向边.[ 输出 ...
- Python获取CPU、内存使用率以及网络使用状态代码
Python获取CPU.内存使用率以及网络使用状态代码_python_脚本之家 http://www.jb51.net/article/134714.htm