hdu1069 Monkey and Banana
2015-12-16 00:14
381 查看
题意:每个箱子有长宽高,只有满足上面的箱子长和宽都比下面的小,才能放,问能将所有符合条箱子高度拼成最大是,对所有按照长宽排个序,
再是裸地最大子段和。
再是裸地最大子段和。
#include <fstream> #include <iostream> #include <string> #include <complex> #include <math.h> #include <set> #include <vector> #include <map> #include <queue> #include <stdio.h> #include <stack> #include <algorithm> #include <list> #include <ctime> #include <memory.h> #include <ctime> #include <assert.h> #define rep(i,a,n) for (int i=a;i<n;i++) #define per(i,a,n) for (int i=n-1;i>=a;i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define eps 1e-8 #define M_PI 3.141592653589793 typedef long long ll; const ll mod=1000000007; const int inf=99999999; ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} struct Node { int x,y,h; }node[200]; bool cmp(Node a,Node b) { return a.x==b.x ? a.y<b.y : a.x<b.x; } int dp[200]; using namespace std; int main() { int n,T=0; while(cin>>n&&n){ int t=0; for(int i=0;i<n;i++){ int a,b,c;cin>>a>>b>>c; node[t].x=a,node[t].y=b,node[t].h=c; node[t+1].x=a,node[t+1].y=c,node[t+1].h=b; node[t+2].x=b,node[t+2].y=a,node[t+2].h=c; node[t+3].x=b,node[t+3].y=c,node[t+3].h=a; node[t+4].x=c,node[t+4].y=a,node[t+4].h=b; node[t+5].x=c,node[t+5].y=b,node[t+5].h=a; t+=6; } int res=0; sort(node,node+t,cmp); for(int i=0;i<t;i++) dp[i]=node[i].h; for(int i=1;i<t;i++){ for(int j=0;j<i;j++){ if(node[i].x>node[j].x&&node[i].y>node[j].y) dp[i]=max(dp[i],dp[j]+node[i].h); } } cout<<"Case "<<++T<<": maximum height = "<<*max_element(dp,dp+t)<<endl; } }
相关文章推荐
- 基于Android中dp和px之间进行转换的实现代码
- Android中dip、dp、sp、pt和px的区别详解
- LFC1.0.0 版本发布
- Android px、dp、sp之间相互转换
- HP data protector软件学习1--基本角色与基本工作流程
- HP data protector软件学习2--软件组成与界面介绍
- android中像素单位dp、px、pt、sp的比较
- Android对px和dip进行尺寸转换的方法
- Android根据分辨率进行单位转换-(dp,sp转像素px)
- android 尺寸 dp,sp,px,dip,pt详解
- DP问题各种模型的状态转移方程
- POJ-1695-Magazine Delivery-dp
- nyoj-1216-整理图书-dp
- TYVJ1193 括号序列解题报告
- 对DP的一点感想
- TYVJ上一些DP的解题报告
- soj1005. Roll Playing Games
- 01背包问题
- LeetCode之Maximum Product Subarray
- DP Flow