题意 给出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 基础动态规划+排序的更多相关文章

  1. 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 ...

  2. HDU 1069 Monkey and Banana dp 题解

    HDU 1069 Monkey and Banana 纵有疾风起 题目大意 一堆科学家研究猩猩的智商,给他M种长方体,每种N个.然后,将一个香蕉挂在屋顶,让猩猩通过 叠长方体来够到香蕉. 现在给你M种 ...

  3. HDU 1069&&HDU 1087 (DP 最长序列之和)

    H - Super Jumping! Jumping! Jumping! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format: ...

  4. HDU 1069—— Monkey and Banana——————【dp】

    Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  5. HDU 1069 dp最长递增子序列

    B - Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  6. HDU 1069 Monkey and Banana(二维偏序LIS的应用)

    ---恢复内容开始--- Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  7. 怒刷DP之 HDU 1069

    Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 1069 Monkey and Banana (DP)

    Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  9. (最大上升子序列)Monkey and Banana -- hdu -- 1069

    http://acm.hdu.edu.cn/showproblem.php?pid=1069      Monkey and Banana Time Limit:1000MS     Memory L ...

随机推荐

  1. javascript输出AscII码扩展集中的字符

    function test(){ var c=""; for(var i=1;i<65536;i++){ if((i%10)==0){ c+=i+':\t'+String.f ...

  2. 如何给Eclipse中添加库(jar包)

    折腾Eclipse时,经常会遇到这种情况: 缺少某个库,找到之后,需要将该库,jar包,加入到当前项目,使得代码中的import xxx得以正常导入. 举例: [已解决]Eclipse的java代码出 ...

  3. 《数学之美》(吴军 著)读书笔记:第1章 文字和语言 vs 数字和信息

    第1章有4个小节,以及前言. 前言 1.信息 2.文字和数字 3.文字和语言背后的数学 4.小结 下面我一一展开,让我们看看每一节都说了什么. 前言 语言和数字都是信息传播的载体,他们之间其实存在着天 ...

  4. Azure DocumentDB对比MongoDB

    (此文章同时发表在本人微信公众号"dotNET每日精华文章") 今天推荐的文章对Azure DocumentDB和MongoDB的进行了比较,也给出了一些使用建议. 我想很多朋友都 ...

  5. myeclipse打war包

    转自:http://wjlvivid.iteye.com/blog/1401707 右键选中项目,选择export然后选择J2EE->WAR File,点击next 接下来指定war包的存放路径 ...

  6. 利用SQLiteOpenHelper来管理SQLite数据库 (转)

    转载自 利用SQLiteOpenHelper来管理SQLite数据库 http://blog.csdn.net/conowen/article/details/7306545 Android学习笔记( ...

  7. MATLAB学习笔记(一)——入门与操作

    (一)简单操作 一.命令行操作 简单的说就跟C语言(更简单来说,就跟手写的一样). 二.变量.数值与表达式 1.变量 (1)命名规则: ①变量名必须以字母开头: ②变量名可以由字母.数字和下画线混合组 ...

  8. Python开发的10个小贴士

    下面是十个Python中很有用的贴士和技巧.其中一些是初学这门语言常常会犯的错误. 注意:假设我们都用的是Python 3 1. 列表推导式 你有一个list:bag = [1, 2, 3, 4, 5 ...

  9. SparkStreaming+Flume出现ERROR ReceiverTracker: Deregistered receiver for stream 0: Error starting receiver 0 - org.jboss.netty.channel.ChannelException

    文章发自http://www.cnblogs.com/hark0623/p/4204104.html ,转载请注明 我发现太多太多的坑要趟了… 向yarn提交sparkstreaming了,提交脚本如 ...

  10. Spring的属性编辑器

    bean类 import java.util.Date; public class Bean { private Date date; public Date getDate() { return d ...