hdu 1069 Monkey and Banana LIS变形
来源:互联网 发布:mac里的照片怎么导出 编辑:程序博客网 时间:2024/05/19 03:20
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1069
题意:
给出n种砖块,砖块是立方体,有三个参数l,w,h,每种有无限个,问砖块可以摞的最大的高度,一个砖块可以摞到另一个上必须底边两边都小于下面的那个。
分析:
最长上升子序列变形题,排序后dp即可。因为每个砖块的三边都可以做长宽高,一共6种可能,也就是说一种砖块相当于6个不一样的砖块。
const int N=200+2;struct block{ int l,w,h; block(){} block(int l,int w,int h):l(l),w(w),h(h){} bool operator < (const block& rhs) const { if(l==rhs.l)return w<rhs.w; return l<rhs.l; }};block b[N];int n,w,l,h,cnt,f[N],cas=0;int main(){ while(~scanf("%d",&n)&&n){ cnt=0; for(int i=0;i<n;i++){ scanf("%d%d%d",&l,&w,&h); b[cnt++]=block(l,w,h); b[cnt++]=block(w,h,l); b[cnt++]=block(h,l,w); b[cnt++]=block(w,l,h); b[cnt++]=block(h,w,l); b[cnt++]=block(l,h,w); } sort(b,b+cnt); int ans=0; for(int i=0;i<cnt;i++){ f[i]=b[i].h; for(int j=0;j<i;j++){ if(b[i].l>b[j].l&&b[i].w>b[j].w&&f[i]<f[j]+b[i].h) f[i]=f[j]+b[i].h; } ans=max(ans,f[i]); } printf("Case %d: maximum height = %d\n",++cas,ans); } return 0;}
0 0
- HDU 1069 Monkey and Banana LIS变形
- hdu 1069 Monkey and Banana LIS变形
- hdu(1069)——Monkey and Banana(LIS变形)
- HDU 1069 Monkey and Banana DP LIS
- 【DP|LIS】HDU-1069 Monkey and Banana
- HDU1069-LIS变形-Monkey and Banana
- HDU 1069 Monkey and Banana (动态规划+LIS)
- 【HDU 1069 】Monkey and Banana 【 求LIS的思想 DP 】
- Monkey and Banana LIS
- HDOJ 1069 Monkey and Banana(LIS)
- HDU 1069 Monkey and Banana
- hdu 1069 Monkey and banana
- hdu 1069 Monkey and Banana
- HDU 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- HDU 1069 Monkey and Banana
- hdu 1069 Monkey and Banana
- 淘宝2011.9.23校园招聘会面试题
- Ubuntu 下 apt-get 更新源推荐
- POJ 1321 棋盘问题
- spring mvc(注解)上传文件的简单例子
- HDU-5818-Joint Stacks-模拟
- hdu 1069 Monkey and Banana LIS变形
- Chessboard
- C++之构造函数与析构函数
- Python3科学计算库的安装
- 用CE来找出对对碰游戏 坐位号基址,棋盘数组基址 并把它读出来
- 第一周《C语言及程序设计》实践项目7 分支结构程序体验
- fread和read的区别
- ZZULIOJ 1908: 小火山的围棋梦想 (DFS)
- ArryaList和LinkedList性能分析和适用场景