#HDU 1069 简单dp

2019-04-14 08:27发布

class="markdown_views prism-dracula"> Monkey and Banana 题意: 给定一些长方体,问可以摆出的最大高度,要求下层长宽必须严格大于上层。 分析: 每个长方体都有三种摆放的顺序呢,那么接下来就把所有情况记录下来搭建积木。 代码如下: #include #include #include #include #include #include #include #include #include #include #include #include #include #define INF 0x3f3f3f3f using namespace std; typedef long long ll; const ll mod = 1e9 + 7; struct node{ int a,b,h; bool operator <(const node s)const{ if(a == s.a) return b < s.b; else return a < s.a; } }box[100]; int dp[100]; int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); int n,kase = 1; while(cin>> n && n){ int s[3],k = 0; for(int i=0;icin>> s[0] >> s[1] >> s[2]; sort(s,s+3); //转换成三个不同高度的长方体 box[k].a = s[0],box[k].b = s[1],box[k].h = s[2];k++; box[k].a = s[0],box[k].b = s[2],box[k].h = s[1];k++; box[k].a = s[1],box[k].b = s[2],box[k].h = s[0];k++; } sort(box,box+k); /*for(int i=0;i for(int i=0;ifor(int i=0;ifor(int j=i+1;j>=0;j--){ if(box[i].a>box[j].a && box[i].b>box[j].b){ if(dp[i]int ans = dp[0]; for(int i=0;iif(ansprintf("Case %d: maximum height = %d ",kase++,ans); } return 0; }