题意 给出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. VS2010 error C3861: “exit”: 找不到标识符

    #include <stdlib.h> 可以解决问题

  2. 组合数(codevs 1631)

    1631 组合数  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 组合数C(N, K)表示 ...

  3. Android之shape属性详解

    有时候 ,为了满足一些需求,我们要用到 shape 去定义 一些背景,shape 的用法 跟图片一样 ,可以给View设置 Android:background="@drawable/sha ...

  4. struts2升级文档

    http://www.linuxdiyf.com/viewarticle.php?id=537212

  5. 有哪些关于 Android 开发的博客值得订阅?

    链接:http://www.zhihu.com/question/19788650/answer/60771437来源:知乎 Google 官方[Android Developers Blog](An ...

  6. HTML5标准学习 – DOCTYPE

    转自:http://www.cnblogs.com/GrayZhang/archive/2011/03/31/learning-html5-doctype.html 上一篇文章主要讲述了HTML文档的 ...

  7. Codeforces Gym 100203G G - Good elements 标记暴力

    G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  8. Activity启动方式

    Activity启动方式有四种,分别是: standard singleTop singleTask singleInstance 可以根据实际的需求为Activity设置对应的启动模式,从而可以避免 ...

  9. Android 编程下如何修改 jar 文件的包名

    首先我们要说说为什么要修改 jar 文件的包名,jar 包我们会非常高频率的使用,尤其是用一些其他三方库的时候,往往把 java 代码打包成 jar 文件,方便项目依赖使用.笔者在开发过程中遇到过一些 ...

  10. ural 1244. Gentlemen

    1244. Gentlemen Time limit: 0.5 secondMemory limit: 64 MB Let's remember one old joke: Once a gentle ...