zoukankan      html  css  js  c++  java
  • hdu 4001 To Miss Our Children Time( sort + DP )

    To Miss Our Children Time

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)
    Total Submission(s): 4075    Accepted Submission(s): 1063


    Problem Description
    Do you remember our children time? When we are children, we are interesting in almost everything around ourselves. A little thing or a simple game will brings us lots of happy time! LLL is a nostalgic boy, now he grows up. In the dead of night, he often misses something, including a simple game which brings him much happy when he was child. Here are the game rules: There lies many blocks on the ground, little LLL wants build "Skyscraper" using these blocks. There are three kinds of blocks signed by an integer d. We describe each block's shape is Cuboid using four integers ai, bi, ci, di. ai, bi are two edges of the block one of them is length the other is width. ci is
    thickness of the block. We know that the ci must be vertical with earth ground. di describe the kind of the block. When di = 0 the block's length and width must be more or equal to the block's length and width which lies under the block. When di = 1 the block's length and width must be more or equal to the block's length which lies under the block and width and the block's area must be more than the block's area which lies under the block. When di = 2 the block length and width must be more than the block's length and width which lies under the block. Here are some blocks. Can you know what's the highest "Skyscraper" can be build using these blocks?
     
     
     
     
    Input
    The input has many test cases.
    For each test case the first line is a integer n ( 0< n <= 1000) , the number of blocks.
    From the second to the n+1'th lines , each line describing the i‐1'th block's a,b,c,d (1 =< ai,bi,ci <= 10^8 , d = 0 or 1 or 2).
    The input end with n = 0.
     
    Output
    Output a line contains a integer describing the highest "Skyscraper"'s height using the n blocks.
     
    Sample Input
     
    3
    10 10 12 0
    10 10 12 1
    10 10 11 2
    2
    10 10 11 1
    10 10 11 1 0
     
    Sample Output
    24
    11

    卡了一下check,在宽>长那里 。

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <vector>
    #include <map>
    #include <vector>
    #include <queue>
    
    using namespace std ;
    typedef long long LL ;
    typedef pair<int,int> pii;
    #define X first
    #define Y second
    const int N = 1010;
    struct Blocks {
        LL a , b , c , d , area ;
        bool operator < ( const Blocks &A ) const {
            if( a != A.a ) return a < A.a ;
            else if( b != A.b ) return b < A.b ;
            else return d > A.d ;
        }
    }e[N];
    LL dp[N] ;
    int main ()  {
        #ifdef LOCAL
            freopen("in.txt","r",stdin);
        #endif // LOCAL
        int _ , cas =1 , n ;
        while( cin >> n && n ) {
            memset( dp , 0 , sizeof dp );
            for( int i = 0 ; i < n ; ++i ) {
                cin >> e[i].a >> e[i].b >> e[i].c >> e[i].d ;
                if(e[i].a > e[i].b ) swap(e[i].a, e[i].b );
                e[i].area =  e[i].a * e[i].b ;
            }
            sort( e  , e + n  ) ;
            for( int i = 0 ; i < n ; ++i ) {
                dp[i] = e[i].c ;
                for( int j = 0 ; j < i ; ++j ) {
                    if( e[i].d == 0 && e[j].a <= e[i].a && e[j].b <= e[i].b )
                        dp[i] = max( dp[i] , dp[j] + e[i].c );
                    if( e[i].d == 1 && e[j].a <= e[i].a && e[j].b <= e[i].b && e[j].area < e[i].area )
                        dp[i] = max( dp[i] , dp[j] + e[i].c );
                    if( e[i].d == 2 && e[j].a < e[i].a && e[j].b < e[i].b )
                        dp[i] = max( dp[i] , dp[j] + e[i].c );
                }
            }
            LL ans = 0 ; for( int i = 0 ; i < n ; ++i ) ans = max( ans , dp[i] );
            cout << ans << endl ;
        }
    }
    View Code
  • 相关阅读:
    mupdf-将pdf转png图片
    Teamcenter二次开发-客户端JAVA开发挂菜单HelloWorld例子
    SqlServer-导入excel表格数据
    PDFlib创建pdf文档
    计算机网络基础知识总结-转载
    到底什么是架构?回答你关于软件架构的所有疑惑。
    SQL语句-获得表的字段数量
    vue3.0---watch使用方法
    小程序picker自定义三级联动
    无法加载文件 D:Program Files odejs ode_globalvue.ps1,因为在此系统上禁止运行脚本。有关详细信息
  • 原文地址:https://www.cnblogs.com/hlmark/p/4296757.html
Copyright © 2011-2022 走看看