To Miss Our Children Time

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

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
 
Source
题解:当时没细想,就是个很水的dp。。。1000两重for,注意long long;
代码:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
const int MAXN = ;
typedef long long LL;
struct Node{
int w, h, c, d;
void init(){
scanf("%d%d%d%d", &w, &h, &c, &d);
if(w > h){
swap(w, h);
}
}
friend bool operator < (Node a, Node b){
if(a.h != b.h)
return a.h < b.h;
if(a.w != b.w)
return a.w < b.w;
return a.d > b.d;
}
};
Node dt[MAXN];
LL dp[MAXN];
bool js(Node a, Node b){
if(b.d == && a.w < b.w && a.h < b.h)
return true;
else if(b.d == && a.w <= b.w && a.h <= b.h && (a.w < b.w || a.h < b.h))
return true;
else if(b.d == && a.w <= b.w && a.h <= b.h)
return true;
return false;
}
int main(){
int n;
while(~scanf("%d", &n), n){
for(int i = ; i < n; i++){
dt[i].init();
}
sort(dt, dt + n);
memset(dp, , sizeof(dp));
LL ans = ;
for(int i = ; i < n; i++){
dp[i] = dt[i].c;
for(int j = ; j < i; j++){
if(js(dt[j], dt[i]))
dp[i] = max(dp[i], dp[j] + dt[i].c);
}
ans = max(ans, dp[i]);
}
printf("%lld\n", ans);
}
return ;
}

To Miss Our Children Time(dp)的更多相关文章

  1. 8VC Venture Cup 2016 - Final Round (Div. 2 Edition)

    暴力 A - Orchestra import java.io.*; import java.util.*; public class Main { public static void main(S ...

  2. WPF制作QQ列表(仿qq列表特效)

    先看效果图:这个是折叠特效. 代码结构:      model是我们的数据模型,定义了在列表显示的人物名称   图片   简介    . Resource是我们的图片资源  和 存储图片资源路径.名称 ...

  3. CF1249F Maximum Weight Subset

    CF1249F Maximum Weight Subset 洛谷评测传送门 题目描述 You are given a tree, which consists of nn vertices. Reca ...

  4. 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 (Jav ...

  5. HDU 4001 To Miss Our Children Time(2011年大连网络赛 A 贪心+dp)

    开始还觉得是贪心呢... 给你三类积木叫你叠楼房,给你的每个积木包括四个值:长 宽(可以互换) 高 类型d d=0:你只能把它放在地上或者放在 长 宽 小于等于 自己的积木上面 d=1:你只能把它放在 ...

  6. hdu 4960 Another OCD Patient(dp)

    Another OCD Patient Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Ot ...

  7. POJ3107Godfather[树形DP 树的重心]

    Godfather Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6121   Accepted: 2164 Descrip ...

  8. codeforces 484D D. Kindergarten(dp)

    题目链接: D. Kindergarten time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  9. 积木(DP)问题

    问题:Do you remember our children time? When we are children, we are interesting in almost everything ...

随机推荐

  1. 在Unity中使用Shader

    1.Material 和 Shader 的关系.一个材质包括一个Shader程序.在Shader中设置的属性能够通过Material可视化设置 2.内建Shader,在5.0之后的版本号中大部分旧的S ...

  2. Linux环境下Eclipse + Tomcat + MySQL 配置J2EE开发环境的方法

    1. 版本号信息 (1)CentOS 6.4发行版64位,uname -a 显演示样例如以下: Linux localhost.localdomain 3.11.6 #1 SMP Sat Nov 2 ...

  3. ulimit 参数介绍

    Linux对于每个用户,系统限制其最大进程数.为提高性能,可以根据设备资源情况,设置各linux 用户的最大进程数 可以用ulimit -a 来显示当前的各种用户进程限制.下面我把某linux用户的最 ...

  4. C#中唯一标识符GUID的一些知识点

    概念 GUID: 即Globally Unique Identifier(全球唯一标识符) 也称作 UUID(Universally Unique IDentifier) . GUID是一个通过特定算 ...

  5. image即时上传

    function preview_upload(input, img_div_id){ var img_id = img_div_id.replace("itempic_previewDiv ...

  6. C# byte[]与char[]、string与char[]、byte[] 与 string 互转

    1. byte array -> char array Byte[] b=new byte[5]{0x01,0x02,0x03,0x04,0x05};  Char[] c=Encoding.AS ...

  7. Tomcat项目部署方式

    一.静态部署 1.直接将web项目文件件拷贝到webapps 目录中      Tomcat的Webapps目录是Tomcat默认的应用目录,当服务器启动时,会加载所有这个目录下的应用.所以可以将JS ...

  8. 激光推送SSL问题

    1.导出极光推送服务器上的证书,导出后文件扩展名是.cer.  下载极光推送服务器上的证书 2.利用极光推送服务器的证书文件,创建客户端密钥库,密钥库的文件扩展名是.jks Dos command: ...

  9. java equals 心得体会

    要记住最有用的一点: equals 在已经被系统定义好的类中 是已经被重写好了的 父类中的 equals方法是比较的两个对象是否指向同一引用 在被定义除了父类以外比较的是两个对象的内容 因此 人为定义 ...

  10. hdu1272并查集入门

    小希的迷宫 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...