HDU1050:Moving Tables
pid=1050">Moving Tables
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19156 Accepted Submission(s): 6532
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.
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 N+3-rd line, the remaining test cases are listed in the same manner as above.
4
10 20
30 40
50 60
70 80
2
1 3
2 200
3
10 100
20 80
30 50
20
30
贪心题,左右两边数可看为一区间。求出最大的区间重叠数再乘以10就可以。。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue> using namespace std; const int maxn = 400 + 50; int cas;
int n;
int p, q;
int vis[maxn];
int ans_minute; int main()
{
scanf("%d", &cas);
while( cas-- )
{
scanf("%d", &n);
memset(vis, 0, sizeof(vis));
while( n-- )
{
scanf("%d%d", &p, &q);
p = (p-1) / 2;//压缩
q = (q-1) / 2;
if( p>q ) swap(p, q);
for(int i=p; i<=q; i++)vis[i]++;
}
int max_repeat = 1;
for(int i=0; i<200; i++)
if( vis[i]>max_repeat )
max_repeat = vis[i];
ans_minute = max_repeat * 10;
printf("%d\n", ans_minute);
}
}
HDU1050:Moving Tables的更多相关文章
- HDU1050(Moving Tables:贪心算法)
解题思路: 这种做法是基于hdu2037的做法上考虑的,找出所有可以同时搬运的桌子,然后就很方便求出最短总时间. 还有一种更简单的做法是直接遍历一遍找出与别的重复次数最多的那片区域,重复次数*10就可 ...
- Hdu1050 Moving Tables 2016-05-19 16:08 87人阅读 评论(0) 收藏
Moving Tables Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floo ...
- HDOJ 1050 Moving Tables
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- Moving Tables
Moving Tables Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- hdoj 1050 Moving Tables【贪心区间覆盖】
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- uvalive 2326 - Moving Tables(区间覆盖问题)
题目连接:2326 - Moving Tables 题目大意:在一个走廊上有400个教室, 先在有一些桌子要移动, 每次移动需要十分钟, 但是不同房间的桌子可以在同一个十分钟内移动,只要走廊没有被占用 ...
- B - Moving Tables
B - Moving Tables Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- POJ1083 Moving Tables
POJ1083 Moving Tables Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35297 Accepted: ...
- POJ 1083 && HDU 1050 Moving Tables (贪心)
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
随机推荐
- TP5 模板渲染语法
每次都要去网上找,又发现都不全.所以自己记录一下 volist:循环 {volist name="collection" id="v"} {/volist} i ...
- who---显示目前登录系统的用户信息
who命令是显示目前登录系统的用户信息.执行who命令可得知目前有那些用户登入系统,单独执行who命令会列出登入帐号,使用的终端机,登入时间以及从何处登入或正在使用哪个X显示器. 语法 who(选项) ...
- 结合Vue 的滚动底部加载
项目手机端分页跳转不理想,自己做了一个滚动加载的一个Demo 核心Dom结构 <body> <div id="Content"> <div> & ...
- P4287 [SHOI2011]双倍回文(回文树)
题目描述 记字符串 w 的倒置为 w^R^ .例如 (abcd)^R^=dcba , (abba)^R^=abba . 对字符串x,如果 x 满足 x^R^=x ,则称之为回文:例如abba是一个回文 ...
- 【ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined) B】Recursive Queries
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 写个记忆化搜索. 接近O(n)的复杂度吧 [代码] #include <bits/stdc++.h> using nam ...
- X的追求道路
X的追求道路 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描写叙述 X在大家的帮助下最终找到了一个妹纸,于是開始了漫漫的追求之路,那 ...
- 17. IntelliJ IDEA + Maven创建Java Web项目
转自:https://www.cnblogs.com/Terry-Wu/p/8006475.html 1. Maven简介 相对于传统的项目,Maven 下管理和构建的项目真的非常好用和简单,所以这里 ...
- centos 7.3 配置vnc 服务 图形界面登录
1.检查系统是否有安装tigervnc-server软件包 rpm -qa |grep vnc 默认的系统未装tigervnc-server软件包 2.安装tigervnc-server软件包 yum ...
- COGS 577 蝗灾 线段树+CDQ分治
第一次写cdq分治 感谢hhd<y 这20亿对CP的指导(逃) 其实 就是 递归看左半部分对右半部分的贡献 (树状数组写挂了--临时改的线段树[大写的尴尬]) //By SiriusRen ...
- POJ 3265 DP
思路: f[i][j]表示前i天能做j道题 (是做 不是做完) if(f[i-1][k]) if(suma[j]-suma[k]+g[i-1][k]<=n) f[i][j]=1,g[i][j]= ...