hdu 1050 Moving Tables
http://acm.hdu.edu.cn/showproblem.php?pid=1050
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm> using namespace std; struct Node
{
int s,t;
int p;
} a[210]; bool cmp(Node a, Node b)
{
return a.t < b.t;
} int main()
{
int t,n,i,j,tim,ma;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i = 0; i < n; i++)
{
a[i].p = 0;
scanf("%d%d",&a[i].s,&a[i].t);
a[i].s = (a[i].s + 1) / 2; //处理奇偶公用一个走量的情况(这个一直没考虑,所以WA)
a[i].t = (a[i].t + 1) / 2;
if(a[i].s > a[i].t) //保证 s < t
{
j = a[i].s;
a[i].s = a[i].t;
a[i].t = j;
}
}
sort(a,a+n,cmp);
ma = 0;
for(i = 0; i < n; i++)
{
tim = 1;
for(j = i+1; j < n; j++)
{
if(a[j].s <= a[i].t)//判断是否有重叠
{
tim++; //增加一个重叠
}
}
if(tim > ma)
{
ma = tim;
}
}
printf("%d\n",ma*10);
} return 0;
}
hdu 1050 Moving Tables的更多相关文章
- POJ 1083 && HDU 1050 Moving Tables (贪心)
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- hdu 1050 Moving Tables 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050 这道题目隔了很久才做出来的.一开始把判断走廊有重叠的算法都想错了.以为重叠只要满足,下一次mov ...
- --hdu 1050 Moving Tables(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050 AC code: #include<stdio.h> #include<str ...
- HDU – 1050 Moving Tables
http://acm.hdu.edu.cn/showproblem.php?pid=1050 当时这道题被放在了贪心专题,我又刚刚做了今年暑假不AC所以一开始就在想这肯定是个变过型的复杂贪心,但是后来 ...
- hdu 1050 Moving Tables (Greedy)
Problem - 1050 过两天要给12的讲贪心,于是就做一下水贪心练习练习. 代码如下: #include <cstdio> #include <iostream> #i ...
- HDU 1050 Moving Tables (贪心)
题意:在一个走廊两边都有对称分布的连续房间,现在有n张桌子需要从a移动到b房间.每次移动需要10分钟, 但是如果两次移动中需要经过相同的走廊位置,则不能同时进行,需要分开移动.最后求最少需要多长时间移 ...
- hdu 1050 Moving Tables(迷之贪心...)
题意:有400间房间按题目中图片所给的方式排列,然后给出要移动的n张桌子所要移动的范围,每张桌子要移动的范围不能出现重叠的区域:问最少要多少次才能移动完所有的桌子. 题解思路:把题目转换下,就是有n个 ...
- HDOJ 1050 Moving Tables
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- 1050 Moving Tables
Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
随机推荐
- SGU481 Hero of Our Time
Description Saratov ACM ICPC teams have a tradition to come together on Halloween and recollect terr ...
- UVA 10896 Sending Email
这个题目真是伤透脑筋了,一直RE,连着改了好几个版本,又是spfa,又是单调队列dijkstra+单调队列,总是不过,后来发现M开小了,双向边应该开m的两倍,悲剧啊!!!以后不管怎样,数组一定要尽量开 ...
- 运行edX Devstack
前一篇文章,我们安装完成了edX Devstack,本文将介绍edX Devstack的常用命令 6.1. 连接到 Devstack Virtual Machine 为了连接到Devstack vir ...
- 网络基本功(八):细说TCP滑动窗口
https://community.emc.com/message/842129#842129
- 140. Word Break II
题目: Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where e ...
- JS 中Promise 模式
异步模式在web编程中变得越来越重要,对于web主流语言Javscript来说,这种模式实现起来不是很利索,为此,许多Javascript库(比如 jQuery和Dojo)添加了一种称为promise ...
- Oracle查询经典
.检索部门编号.部门名称.部门所在地及其每个部门的员工总数. select d.deptno,d.dname,d.loc,count(*) from emp e,dept d where e.dept ...
- c程序设计语言_习题1-9_将输入流复制到输出流,并将多个空格过滤成一个空格
Write a program to copy its input to its output, replacing each string of one or more blanks by a si ...
- (转载)CentOS: 开放80、22、3306端口操作
(转载)http://blog.sina.com.cn/s/blog_3eba8f1c0100tsox.html #/sbin/iptables -I INPUT -p tcp --dport 80 ...
- C# using Sendkey function to send a key to another application
If notepad is already started, you should write: // import the function in your class [DllImport (&q ...