HDU 1069 Monkey and Banana DP lis deformation problem

Source: Internet
Author: User

http://acm.hdu.edu.cn/showproblem.php?pid=1069

This means that given n types of chests, each box has an infinite number of boxes, each with three parameters (x, y, z) to determine.

You can choose any of the two parameters as long and wide, and the third one is high.

Then asked to put the box up, so that the height of the highest.

The premise of the case is the length and width of the box below > the box above.

Ideas:

Because the same box can produce 6 different boxes, and each of the most selected, because the same box at most can only be set up one.

So you can get all the boxes out, sort of, is the LIS topic.

Dp[i] represents with I this box for the maximum height of the end.

#include <cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<algorithm>#defineIOS Ios::sync_with_stdio (False)using namespacestd;#defineINF (0X3F3F3F3F)typedefLong Long intLL; #include<iostream>#include<sstream>#include<vector>#include<Set>#include<map>#include<queue>#include<string>Const intMAXN =100000+ -;intN;structNode {intL, W, H; Node (intLL,intWwintHH): L (LL), W (WW), H (HH) {} node () {}BOOL operator< (Const structNode & RHS)Const {        if(L! = RHS. LreturnL >RHS.        L Else if(W! = RHS. WreturnW >RHS.        W Else returnH >RHS.    H }}A[MAXN];intDP[MAXN];BOOLisOKintOneintBoth ) {    if(A[one]. L > A[two]. L && A[one]. W > A[two]. Wreturn true; Else return false;}voidWork () {intt =0;  for(inti =1; I <= N; ++i) {intx, y, Z; CIN>> x >> y >>Z; a[++T] =node (x, y, z); a[++T] =node (x, z, y); a[++T] =node (y, x, z); a[++T] =node (y, z, x); a[++T] =node (z, x, y); a[++T] =node (z, y, x); } sort (A+1, A +1+t);  for(inti =1; I <= t; ++i) {Dp[i]=A[i].        H  for(intj =1; J < I; ++j) {if(isOK (J, i)) {Dp[i]= Max (Dp[i], dp[j] +A[i].            H); }        }    }    intAns =-inf;  for(inti =1; I <= t; ++i) {ans=Max (ans, dp[i]); }    Static intf =0; printf ("Case %d:maximum height =%d\n", ++F, ans);}intMain () {#ifdef local freopen ("Data.txt","R", stdin);#endif//IOS;     while(Cin >> N &&N) work (); return 0;}
View Code

HDU 1069 Monkey and Banana DP lis deformation problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.