HDU 4001 to Miss our children time DP

Source: Internet
Author: User

Poke here: HDU 4001

Test instructions: There are three kinds of bricks, the No. 0 type can only be placed in the length and width is strictly less than its building blocks, the 1th can only be placed in the length and width is less than equal to it and the area is less than its building blocks, 2nd type can only be placed in the length and width is less than equal to its building blocks, DP to the highest

1#include"bits/stdc++.h"2 using namespacestd;3 intN;4 structBlock5 {6     intA, B, C, D;7}block[1010];8 BOOLCMP (Block A, block B)9 {Ten     if(A.A! =B.A) { One         returnA.A <B.A; A     } -     if(A.B! =b.b) { -         returnA.B <b.b; the     } -     returnA.D >B.D; - } -  + Long Longdp[1010]; -  + intMain () A { at      while(SCANF ("%d", &n) &&N) { -Memset (DP,0,sizeof(DP)); -         inti; -          for(i =1; I <= N; ++i) { -scanf"%d%d%d%d", &AMP;BLOCK[I].A, &block[i].b, &AMP;BLOCK[I].C, &block[i].d); -             if(Block[i].a >block[i].b) { in swap (BLOCK[I].A, block[i].b); -             } to         } +Sort (Block +1, Block +1+N, CMP); -         intJ; the          for(i =1; I <= N; ++i) { *              for(j =0; J < I; ++j) { $                 if(BLOCK[I].D = =0) {Panax Notoginseng                     if(block[j].a <= block[i].a && block[j].b <=block[i].b) { -Dp[i] = max (Dp[i], dp[j] +block[i].c); the                     } +                 } A                 if(BLOCK[I].D = =1) { the                     if((block[j].a <= block[i].a && block[j].b < block[i].b) | | (Block[j].a < block[i].a && block[j].b <=block[i].b)) { +Dp[i] = max (Dp[i], dp[j] +block[i].c); -                     } $                 } $                 if(BLOCK[I].D = =2) { -                     if(Block[j].a < block[i].a && block[j].b <block[i].b) { -Dp[i] = max (Dp[i], dp[j] +block[i].c); the                     } -                 }Wuyi             } the         } -         Long Longres =0; Wu          for(i =1; I <= N; ++i) { -res =Max (res, dp[i]); About         } $printf"%i64d\n", res); -     } -}

HDU 4001 to Miss our children time DP

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.