[HDU 1069 Monkey and Banana]DP

Spring Boot集成Jasypt踩坑实录:自定义SM4加密器Bean加载失败的终极解决方案 本文深入剖析了Spring Boot集成Jasypt时自定义SM4加密器Bean加载失败的根源,即Spring Boot启动流程中Bean加载顺序与Jasypt自动配置的时序冲突。文章提供了三种从源码层面解决问题的有效方案,包括使用ApplicationContextInitializer提前注册、调整Bean依赖顺序以及自定义PropertySource处理机制,并给出了完整的国密SM4加密器实现与测试示例。 阅读详情

题目链接  http://acm.hdu.edu.cn/showproblem.php?pid=1069

Monkey and Banana

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9902    Accepted Submission(s): 5152


Problem Description
A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monkey is clever enough, it shall be able to reach the banana by placing one block on the top another to build a tower and climb up to get its favorite food.

The researchers have n types of blocks, and an unlimited supply of blocks of each type. Each type-i block was a rectangular solid with linear dimensions (xi, yi, zi). A block could be reoriented so that any two of its three dimensions determined the dimensions of the base and the other dimension was the height.

They want to make sure that the tallest tower possible by stacking blocks can reach the roof. The problem is that, in building a tower, one block could only be placed on top of another block as long as the two base dimensions of the upper block were both strictly smaller than the corresponding base dimensions of the lower block because there has to be some space for the monkey to step on. This meant, for example, that blocks oriented to have equal-sized bases couldn't be stacked.

Your job is to write a program that determines the height of the tallest tower the monkey can build with a given set of blocks.
 

Input
The input file will contain one or more test cases. The first line of each test case contains an integer n,
representing the number of different blocks in the following data set. The maximum value for n is 30.
Each of the next n lines contains three integers representing the values xi, yi and zi.
Input is terminated by a value of zero (0) for n.
 

Output
For each test case, print one line containing the case number (they are numbered sequentially starting from 1) and the height of the tallest possible tower in the format "Case case: maximum height = height".
 

Sample Input
  
1 10 20 30 2 6 8 10 5 5 5 7 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 5 31 41 59 26 53 58 97 93 23 84 62 64 33 83 27 0
 

Sample Output
  
Case 1: maximum height = 40 Case 2: maximum height = 21 Case 3: maximum height = 28 Case 4: maximum height = 342
 

Source
 
其实蛮简单的,思考一下就可以了。
题目意思是给你n个长方体的长宽高,长方体能用各种姿态摆,也就是长能做宽宽能做高高能做长,随意变化。。。
每一种长方体的个数无限,稍微想想就知道一个长方体能摆3个姿势,长宽高能定6种。
然后让你把这些长方体像金字塔一样堆叠起来,上面的长方体要小于下面的长方体,宽和长都要小于下面长方体的宽和长,让你求出能摆出的最高高度。
其实就是最大子序列和,写出转移方程的条件就行。
我的做法是,每给你一个长方体的数据,就存6种长方体,然后按照长或者宽从小到大排序,用dp记录用当前长方体做低能堆叠出的最高高度。

代码如下
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef struct node   //开个结构体数组,用来记录dp值和长宽高
{
    int x, y, z;
    int dp;
};
int cmp(node a, node b)
{
    return a.x < b.x;
}
node nod[185];
int n;
int main()
{
//    freopen("input.txt", "r", stdin);
    int s[3];
    int a, b, c;
    int cnt;
    int tt = 1;
    while (scanf("%d", &n) != EOF&&n)
    {
        cnt = 1;
        for (int i = 1; i <= n; i++)
        {
            scanf("%d%d%d", &s[0], &s[1], &s[2]);
            sort(s, s + 3);
            nod[cnt].x = s[0];    //冗长的储存。。。
            nod[cnt].y = s[1];
            nod[cnt].z = s[2];
            nod[cnt++].dp = s[2];
            nod[cnt].x = s[1];
            nod[cnt].y = s[0];
            nod[cnt].z = s[2];
            nod[cnt++].dp = s[2];
            nod[cnt].x = s[1];
            nod[cnt].y = s[2];
            nod[cnt].z = s[0];
            nod[cnt++].dp = s[0];
            nod[cnt].x = s[2];
            nod[cnt].y = s[1];
            nod[cnt].z = s[0];
            nod[cnt++].dp = s[0];
            nod[cnt].x = s[2];
            nod[cnt].y = s[0];
            nod[cnt].z = s[1];
            nod[cnt++].dp = s[1];
            nod[cnt].x = s[0];
            nod[cnt].y = s[2];
            nod[cnt].z = s[1];
            nod[cnt++].dp = s[1];
        }
        sort(nod, nod + cnt, cmp);  //按照宽或者长从小到大排序
        for (int i = 1; i < cnt; i++)
        {
            for (int j = 1; j < i; j++)
            {
                if (nod[i].x > nod[j].x && nod[i].y > nod[j].y)  //长/宽都要大于上面的长方体的长/宽
                    nod[i].dp = max(nod[i].dp, nod[j].dp + nod[i].z);
            }
        }
        int mx = -1;
        for (int i = 1; i < cnt; i++)   //取最大值
            mx = max(mx, nod[i].dp);
        printf("Case %d: maximum height = %d\n", tt++, mx);
    }
    return 0;
}



微信小程序获取用户手机号全流程实战(附完整代码) 本文详细介绍了微信小程序获取用户手机号的全流程实战,包括前端授权、后端解密及安全合规要点。通过传统授权按钮和新版手机号快速验证组件两种方案,帮助开发者高效实现功能,并附完整代码示例。重点解析了微信小程序接口的使用技巧和常见问题解决方案,确保数据安全与用户体验。 阅读详情

相关推荐

MinIO vs 华为云OBS:成本、性能与兼容性深度对比(含实测数据)

本文深度对比了开源对象存储MinIO与华为云OBS在成本、性能、兼容性及运维方面的核心差异。通过实测数据与全生命周期成本分析,为技术决策者提供选型依据。文章指出,MinIO在长期成本控制、性能深度优化及S3 API兼容性方面优势显著,而华为云OBS则提供开箱即用的便利性。

kmeans3miner的博客 622

HDU1069-Monkey and Banana 【DP】

题目地址:https://cn.vjudge.net/problem/HDU-1069 看了一下这个DP教程,受到启发来做这题,一开始solve函数是这么写的 int solve() { getpre(); memset(dp,0,sizeof(dp)); dp[0][0] = 0; dp[0][1] = bl[0].c; for(int i=1;i&...

好好学习天天向上 3299

C51单片机驱动ILI9341彩屏实战:从Proteus仿真到绘制自定义图案(附完整代码)

本文详细介绍了使用C51单片机驱动ILI9341彩屏的完整实战流程。内容涵盖硬件连接、8080并行接口时序模拟、寄存器初始化、屏幕方向设置以及基本图形绘制原理,并重点讲解了如何在Proteus仿真环境中搭建电路、调试代码,最终实现自定义图案的显示。文章提供了完整的代码示例,为嵌入式开发学习者和复古硬件爱好者提供了一套可行的解决方案。

rnn9storyteller的博客 529

HDU1069 Monkey and Banana (DP)

HDU1069 Monkey and Banana (DP) HDU1069 Monkey and Banana DP 题意 思路 AC代码 原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=1069 题意 有n个小块,每个块能摆成6种方案,每个小块提供无数个,下一层的长宽都必须严格大于上一层的长与宽。问最高能够叠多高。 ...

HuiSeKongHuan的博客 393

告别环境配置烦恼:Docker容器化一站式搭建Zephyr RTOS开发环境

本文详细介绍了如何使用Docker容器化技术一站式搭建Zephyr RTOS开发环境,彻底解决环境配置不一致、依赖冲突等难题。通过预构建镜像、数据卷挂载和实战编译示例,帮助开发者快速获得隔离、一致且可复现的嵌入式开发环境,大幅提升开发效率和团队协作体验。

n8m7b6v5c4的博客 196

基于Codex平台与AI Agent技能开发,实现抖音爆款视频分析与脚本自动生成

大家好,我是专注于AI应用开发的技术博主。最近在探索如何利用AI工具自动化内容创作时,我发现了一个非常有趣的组合:通过Codex平台创建自定义的Skill(技能),来批量分析抖音平台的爆款视频,并基于分析结果自动生成新的带货视频脚本。这听起来像是内容团队的“黑科技”,但实现起来其实有清晰的路径可循。本文将为你完整拆解这个实战项目,从环境搭建、Skill编写、数据抓取到视频脚本生成,手把手教你打造自己的“AI内容助理”。无论你是想了解AI Agent的开发,还是对短视频自动化创作感兴趣,都能从本文中获得可直接

weixin_34110749的博客 666

HDU 1069 Monkey and Banana dp 题解

HDU 1069 Monkey and Banana 题解 纵有疾风起 题目大意 一堆科学家研究猩猩的智商,给他M种长方体,每种N个。然后,将一个香蕉挂在屋顶,让猩猩通过 叠长方体来够到香蕉。 现在给你M种长方体,计算,最高能堆多高。要求位于上面的长方体的长要大于(注意不是大于等于)下面长方体的长,上面长方体的宽大于下面长方体的宽。 输入输出 开始一个数n,表示有多少种木块,木块...

weixin_30433075的博客 175

论文翻译:2024 High-Confidence Computing A survey on large language model (LLM) security and privacy: The

大型语言模型(LLMs),如ChatGPT和Bard,已经彻底改变了自然语言理解和生成。它们具有深度语言理解能力、类似人类的文本生成能力、上下文意识和强大的问题解决技能,使它们在各个领域(例如搜索引擎、客户支持、翻译)中变得不可或缺。同时,LLMs也在安全领域获得了关注,揭示了安全漏洞并展示了它们在安全相关任务中的潜力。本文探讨了LLMs与安全性和隐私的交集。具体来说,我们研究了LLMs如何积极影响安全性和隐私,与它们使用相关的潜在风险和威胁,以及LLMs内部的固有漏洞。

CSPhD-winston的博客 1733

hdu 1069 Monkey and Banana DP

传送门:hdu 1069 Monkey and Banana题目大意一堆科学家研究猩猩的智商,给他M种长方体,每种N个。然后,将一个香蕉挂在屋顶,让猩猩通过 叠长方体来够到香蕉。现在给你M种长方体,计算,最高能堆多高。要求位于上面的长方体的长要小于(注意不是小于于等于)下面长方体的长,上面长方体的宽小于下面长方体的宽。解题思路每一种长宽高不同的箱子来说,最多有六种摆放方式, 把这六种摆放的样式全部

woshinannan的专栏 435

如何解决Dify重新部署(升级到最新版)后出现的Setup failed: PermissionDenied等问题

重新部署(升级)Dify后遇到Permission denied错误?🚫 本文详细分析了这个问题的原因🔐,并提供了完整的解决步骤来修复这个问题✨

XiaoqiangClub的博客 1681

AI Agent 入门(一):什么是 AI Agent?——从概念到第一个 API 调用

AI Agent 入门(一):什么是 AI Agent?——从概念到第一个 API 调用

nbtang的博客 262

C - Monkey and Banana HDU - 1069——基础dp

Think: 1知识点:基础dp 2题意:询问n种箱子在满足 1>可以不同面为底 2>一个叠一个 3>叠的箱子中上面的箱子长和宽都严格小于下面的箱子的长和宽 4>无限个箱子 条件下能够叠的最高高度vjudge题目链接以下为Accepted代码——基础dp#include <cstdio> #include <cstring> #include <algorithm>using name

BlessingXRY的博客 506

以 DeleteRestrictions 与 inlineDelete 为核心的 Fiori Elements 表格删除机制全解

SAP Fiori elements 中删除操作的设计与实现涉及多维度考量。框架默认依据 OData 元数据判断删除能力,通过 DeleteRestrictions 注解实现行级条件控制(deletable-path)。表格支持两种删除模式:工具栏集中删除与响应式表格行内删除,但二者不建议混用。关键约束包括:行内删除仅适用于 Responsive Table,且与多选功能互斥。配置需遵循三层架构:后端能力注解、前端表格形态和运行时交互。设计上强调禁用优于隐藏的可用性原则,并需保持列表页与对象页的删除体验一致

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 163

ACM-经典DP之Monkey and Banana——hdu1069

  ***************************************转载请注明出处:http://blog.csdn.net/lttree*************************************** Monkey and Banana   Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 6553...

继续激情,继续奋斗。 7754

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

HDU1069 Monkey and Banana —— DP

题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1069 Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16589A...

alince20008的博客 161

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Linux文件系统详解:从基础概念到高级挂载技巧

文件系统是操作系统管理存储设备的核心机制,Linux采用独特的单一目录树结构组织存储资源。从底层原理看,文件系统通过超级块、inode表和目录项等组件实现数据的高效存取。ext4、XFS等主流文件系统类型各有特点,工程师需要根据性能需求、功能特性和兼容性要求进行选择。在实际应用中,通过mount命令和fstab配置可以实现灵活的挂载管理,而bind mount、tmpfs等高级技巧则能满足容器化、内存文件系统等特殊场景需求。文件系统性能优化涉及挂载选项调整、日志模式选择等多个维度,合理的配置可以显著提升数据

aofan9566的博客 322

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

[HDU 1069 DP]Monkey and Banana

方法1: dp[i][j]记为在第i层使用第j块block的最大高度。三重for循环: #include<bits/stdc++.h> #define pb push_back using namespace std; const int N = 95; int n; typedef long long ll; struct block{ int x,y,h; block(int _x,int _y,int _h):x(_x),y(_y),h(_h){ } }; vector<b

我们仍未知道那天所看见的花的名字。 124

HDU 1069 Monkey and Banana DP

Monkey and Banana Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u SubmitStatusDescription A group of researchers are designing an experiment to test the IQ of a mo

Katapeltes 599

HDU1069 Monkey and Banana DP

题意:给你一些不同的方块,每种方块可以用无限个,当上一方块的底面长宽都小于下一方块的底面时两方块可以叠在一起,求这些方块叠起来的最高高度 思路:由于方块可以翻转,故底面有六种情况,每种方块把六种情况都做考虑,取dp[i]为第i个方块为底的时最大高度,则dp[i]=block[i].z+max(dp[j]),0<j<i,即当前最大高度等于当前方块高度加上可以放在i上面的最大高度,求出每个...

qq_42397248的博客 189

HDU 1069 Monkey and Banana (DP)

DP

yohanlong的专栏 309

hdu 1069 Monkey and Banana dp

题意:给你n种个长方体,告诉你每种长方体的长,宽,高,并且每种长方体个数不限 问:把它们堆起来的最大高度 限制条件:上面一个长方体a的底面积,必须比它下面一个长方体b的底面积大,而且,a的底面的长宽也要大于b的底面的长宽 所以,b的底面积如果比a的底面积小,b也不一定能放在a上面 View Code #include <iostream>#include &l...

diaopi1575的博客 177

HDU 1069 Monkey and Banana(dp)

题目链接:HDU 1069 Monkey and Banana dp。 我认为这道题难点在于解决方块无限个的问题,转化到代码中就是一个方块变成六个方块。然后排序,剩下就简单了。 blocks[i].height表示第i个块在最底下时候的最大高度。 具体看代码吧。 #include #include #include using namespace std; const in

fobdddf的专栏 583

HDU 1069 Monkey and Banana【DP】

Problem Description A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey wit...

dianxuanzhi1019的博客 134

hdu1069 Monkey and Banana dp

题目链接:http://hdu.hustoj.com/showproblem.php?pid=1069                                                                                                                    Monkey and Banana Ti

一七得七 406

HDU 1069 Monkey and Banana Dp问题

题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68966#problem/C 题意:给定一些长方体的尺寸,数量都是无限个,然后求这写长方体能堆切成的最大高度。PS:接触面的上面必须严格小于下面的面。 这题和紫书P269的巴比伦塔例题差不多,可以说是一模一样,紫书上把这种题型叫DAG上最长路。看了别人的代码AC的。 思路:

catch_catch的专栏 651

HDU1069 Monkey and Banana【基础DP】

Monkey and Banana 题意: 有n种类型的砖块,每种类型的砖块都有无限个。第i块砖块的长宽高分别用xi,yi,zi来表示。 同时,由于砖块是可以旋转的,每个砖块的3条边可以组成6种不同的长宽高。在构建塔时,当且仅当A砖块的长和宽都分别小于B砖块的长和宽时,A砖块才能放到B砖块的上面,计算最高可以堆出的砖块们的高度。 题解: 因为一块砖有六个形态,直接将每个形态确定为一种砖块,然后排好序(随便以什么依据,但一定要排好序)。要明确一点,是不能用贪心做的,因为也许在A砖上放置了B,不...

lllllan 166
上一篇: [HDU 2571 命运]简单DP
下一篇: [HDU 1171 Big Event in HDU]背包
chenningGo
博客等级 码龄11年 1粉丝 17原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值