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. Enabling Active Directory Authentication for VMWare Server running on Linux《转载》

    Enabling Active Directory Authentication for VMWare Server running on Linux Version 0.2 - Adam Breid ...

  2. 无法从带有索引像素格式的图像创建graphics对象(转)

    大家在用 .NET 做图片水印功能的时候, 很可能会遇到 “无法从带有索引像素格式的图像创建graphics对象”这个错误,对应的英文错误提示是“A Graphics object cannot be ...

  3. 关于IE11

    最近,一个开发代号为Windows Blue的Windows操作系统泄漏到了互联网上,该操作系统的内置浏览器为IE11,本文将介绍一下这个泄漏版的IE11中有哪些关键的新变化和新特性. 预先声明: 本 ...

  4. C#的位运算符

    C#的位运算符&,| ,^ ,<<,>>2008年08月01日 星期五 15:52位 运 算我们知道任何信息在计算机中都是以二进制的形式保存的位操作符就是对数据按二进制 ...

  5. hdu 确定比赛名次

    算法:拓扑排序 题意:有一个比赛,现在知道很多队之间的关系:让你去让确定比赛排名: Problem Description 有N个比赛队(1<=N<=500),编号依次为1,2,3,... ...

  6. 洛谷 P3397 地毯

    P3397 地毯 题目背景 此题约为NOIP提高组Day2T1难度. 题目描述 在n*n的格子上有m个地毯. 给出这些地毯的信息,问每个点被多少个地毯覆盖. 输入输出格式 输入格式: 第一行,两个正整 ...

  7. 视觉差效果 - jqyery scrollTop原理

    原理是用页面的滚动高度scrollTop()来控制背景图的位置 附上源码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transition ...

  8. cobbler之ks文件示例

    #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration,关闭防火墙 firewall --disabl ...

  9. django的model对象转化成dict

    今天发现一个掉渣天的方法,Django的forms包里面有一个方法:model_to_dict(),它可以将一个model对象转化成dict. In [1]: from apps.dormitory. ...

  10. 必须弄懂的495个C语言问题

    1.1 我如何决定使用那种整数类型? 如果需要大数 值(大于32, 767 或小于¡32, 767), 使用long 型.否则, 如果空间很重要(如有大数组或很多结构), 使用short 型.除此之外 ...