zoukankan      html  css  js  c++  java
  • HDU 1069

    // 题意 : 给出立方体长宽高 ,求摆放的最高高度,摆放在下面的立方体长宽大于上方的 
    
    #include<cstdlib>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    using namespace std;
    const int INF = 0x3f3f3f3f;
    const int maxn = 200;
    int len[200];
    struct node
    {
        int x,y,z;
        void init(int xx,int yy, int zz)
        {
            x = xx; y = yy; z = zz;
        }
    };
    node a[200];
    bool cmp(node a,node b)
    {
        return (a.x*a.y < b.x*b.y);    
    }
    int main()
    {
        int t=1,n,x,y,z;
        while(scanf("%d",&n)!=EOF && n)
        {
            int cnt=0;
            for(int i=0;i<n;i++)
            {
                scanf("%d%d%d",&x,&y,&z);
                a[cnt++].init(x,y,z); a[cnt++].init(y,z,x);
                a[cnt++].init(x,z,y); a[cnt++].init(y,x,z);
                a[cnt++].init(z,x,y); a[cnt++].init(z,y,x);            //六种摆放的方式 
            }
            sort(a,a+cnt,cmp); // 按底面积排序 
            int mx=0;
            for(int i=0;i<cnt;i++ )  //LIS 
            {
                len[i] = a[i].z;
                for(int j=0;j<i;j++)
                {
                    if(a[j].x < a[i].x && a[j].y < a[i].y)
                    {
                        len[i] = max(len[i], len[j] + a[i].z);
                        mx = max(mx, len[i]);
                    }
                
                }
            }    
            printf("Case %d: maximum height = %d
    ",t++,mx);
        } 
        
        return 0;
    }
  • 相关阅读:
    dubbo springcloud区别
    rpc
    centos7 安装docker
    vibox安装
    知识点
    spring cloud
    微服务设计原则
    工具类
    xss--知识点
    java基础--注解
  • 原文地址:https://www.cnblogs.com/ember/p/5342785.html
Copyright © 2011-2022 走看看