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", &BLOCK[I].A, &block[i].b, &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