HDU 1069 基础动态规划+排序
题意 给出n种立方体石头 当且仅当一块石头的底部宽度长度都小于一块石头的时候才能放在上面 问最高能放多高?石头不限数目
然而同样一种石头采用同样的摆放方式 两快相同石头一定无法进行放置 所以 一块石头的一种摆放方式最多使用一次
进行一下排序 让长与宽最小的放在最前面 然后就是可爱的dp模板了
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<math.h>
using namespace std;
struct node
{
int a,b,c;
};
node q[50000];
int dp[50000];
int cmp(node z,node x)
{
if(z.b==x.b)
return z.a>x.a;
else return z.b>x.b;
}
int main(){
int n;
int tt=1;
while(~scanf("%d",&n))
{
if(n==0)
break;
int w=0;
for(int i=0;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
q[w].a=x;
q[w].b=y;
q[w++].c=z;
q[w].a=y;
q[w].b=x;
q[w++].c=z;
q[w].a=y;
q[w].b=z;
q[w++].c=x;
q[w].a=z;
q[w].b=y;
q[w++].c=x;
q[w].a=x;
q[w].b=z;
q[w++].c=y;
q[w].a=z;
q[w].b=x;
q[w++].c=y;
}
sort(q,q+w,cmp);
dp[0]=q[0].c;
for(int i=1;i<w;i++)
{
int minn=0;
for(int k=0;k<i;k++)
{
if(q[k].a>q[i].a&&q[k].b>q[i].b)
{
if(dp[k]>minn)
{
minn=dp[k];
}
}
}
dp[i]=q[i].c+minn;
}
int ans=0;
for(int i=0;i<w;i++)
{
if(dp[i]>ans)
{
ans=dp[i];
}
}
printf("Case %d: maximum height = %d\n",tt++,ans);
}
}
HDU 1069 基础动态规划+排序的更多相关文章
- HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径)
HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径) Description A group of researchers ar ...
- HDU 1069 Monkey and Banana dp 题解
HDU 1069 Monkey and Banana 纵有疾风起 题目大意 一堆科学家研究猩猩的智商,给他M种长方体,每种N个.然后,将一个香蕉挂在屋顶,让猩猩通过 叠长方体来够到香蕉. 现在给你M种 ...
- HDU 1069&&HDU 1087 (DP 最长序列之和)
H - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
- HDU 1069—— Monkey and Banana——————【dp】
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 1069 dp最长递增子序列
B - Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
- HDU 1069 Monkey and Banana(二维偏序LIS的应用)
---恢复内容开始--- Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- 怒刷DP之 HDU 1069
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 1069 Monkey and Banana (DP)
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- (最大上升子序列)Monkey and Banana -- hdu -- 1069
http://acm.hdu.edu.cn/showproblem.php?pid=1069 Monkey and Banana Time Limit:1000MS Memory L ...
随机推荐
- NEXTDAY
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "com_time ...
- SRAM的读写操作
自己写的SRAM的程序,主要在于实用性,适应工作的工程需要.使用芯片为: 芯片时序图为: 代码: /********************************Copyright********* ...
- ubuntu 安装zabbix_agent端
root@(none):~# apt-get install zabbix-agent root@(none):~# vi /etc/zabbix/zabbix_agentd.conf Server= ...
- Oracle Undo与脏读解析
Undo就是用来记录保存事务操作过程中的数据,如果事务发生错误,可以之前的数据进行填补. Undo segment 是保存在表空间上的.Undo 大小是固定的,既然是固定的也就是有限的.如果保存的记录 ...
- Android Studio 获取 sha1-wangfeng520@
WIN+R 打开“运行” 输入 CMD 回车 2 CD C:\Program Files\Java\jdk1.7.0_71\bin (JDK安装路径) keytool -list -v ...
- git中进入带有空格的目录下的解决办法
比如:要进入Program Files目录下 有两种方法: 1.将Program Files目录用引号引起来. $ cd "Program Files" 2.将空格处使用空格引号 ...
- 计算几何 HDOJ 4720 Naive and Silly Muggles
题目传送门 /* 题意:给三个点求它们的外接圆,判断一个点是否在园内 计算几何:我用重心当圆心竟然AC了,数据真水:) 正解以后补充,http://www.cnblogs.com/kuangbin/a ...
- MD5算法 简介
MD5(单向散列算法)的全称是Message-Digest Algorithm 5(信息-摘要算法),经MD2.MD3和MD4发展而来.MD5算法的使用不需要支付任何版权费用. MD5功能 l 输入任 ...
- python 代码片段7
#coding=utf-8 #列表 book=['python','development',8] book.append(2008) print book book.insert(1,'web') ...
- BZOJ3012 : [Usaco2012 Dec]First!
建立Trie,那么成为答案的串必须满足其终止节点到根路径上没有其它点. 对于Trie上每个节点维护一个bitset,表示哪些字符必须在哪些字符之前. 每到达一个可能成为答案的终止节点,对图进行拓扑排序 ...