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
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?
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.
0
卡了一下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 = ;
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 = , n ;
while( cin >> n && n ) {
memset( dp , , sizeof dp );
for( int i = ; 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 = ; i < n ; ++i ) {
dp[i] = e[i].c ;
for( int j = ; j < i ; ++j ) {
if( e[i].d == && 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 == && 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 == && e[j].a < e[i].a && e[j].b < e[i].b )
dp[i] = max( dp[i] , dp[j] + e[i].c );
}
}
LL ans = ; for( int i = ; i < n ; ++i ) ans = max( ans , dp[i] );
cout << ans << endl ;
}
}
hdu 4001 To Miss Our Children Time( sort + DP )的更多相关文章
- HDU 4001 To Miss Our Children Time(2011年大连网络赛 A 贪心+dp)
开始还觉得是贪心呢... 给你三类积木叫你叠楼房,给你的每个积木包括四个值:长 宽(可以互换) 高 类型d d=0:你只能把它放在地上或者放在 长 宽 小于等于 自己的积木上面 d=1:你只能把它放在 ...
- hdu 4057 AC自己主动机+状态压缩dp
http://acm.hdu.edu.cn/showproblem.php?pid=4057 Problem Description Dr. X is a biologist, who likes r ...
- 【HDU 5647】DZY Loves Connecting(树DP)
pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS ...
- HDOJ(HDU).1025 Constructing Roads In JGShining's Kingdom (DP)
HDOJ(HDU).1025 Constructing Roads In JGShining's Kingdom (DP) 点我挑战题目 题目分析 题目大意就是给出两两配对的poor city和ric ...
- HDU 1160 FatMouse's Speed (sort + dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1160 给你一些老鼠的体重和速度,问你最多需要几只可以证明体重越重速度越慢,并输出任意一组答案. 结构体 ...
- poj 4001 To Miss Our Children Time
To Miss Our Children Time Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Jav ...
- hdu 4001 dp 2011大连赛区网络赛A
题意:给一些指定长宽高的砖,求能累出的最大高度,不同砖有不同编号,每种编号对下面的砖做出了限制 dp 注意输出要用%I64d,否则会wa,以后不用%lld了 Sample Input 3 10 10 ...
- HDU 5794 A Simple Chess (容斥+DP+Lucas)
A Simple Chess 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5794 Description There is a n×m board ...
- HDU 3920 Clear All of Them I(DP + 状态压缩 + 贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3920 题目大意:你在一个位置用激光枪灭敌人,给你初始位置,下面是2*n个敌人的位置,你一枪能杀两个,可 ...
随机推荐
- idea旗舰版续命
首先鼓励大家使用正版!我一直用的是免费的社区版,但发现有一些功能被阉割了,比如weblogbic就不支持,无奈现在的项目要用到这个,只能去下载旗舰版. 旗舰版需要付费,作为程序员的我为了一个临时的项目 ...
- 分布式锁的实现【基于ZooKeeper】
引言 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件.它是一个为分布式应用提供一致性服务的软件,提 ...
- ps:消除锯齿和羽化
我们使用椭圆选框工具,分别关闭和打开消除锯齿(也称抗锯齿),创建两个差不多大的正圆形选区,然后填充黑色看看.怎样快速填充黑色还记得吗?先[X]然后[ALT DELETE].填充之后取消选择[CTRL ...
- 函数柯里化(Currying)小实践
什么是函数柯里化 在计算机科学中,柯里化(Currying)是把接受多个参数的函数变换成接受一个单一参数(最初函数的第一个参数)的函数,并且返回接受余下的参数且返回结果的新函数的技术.这个技术由 Ch ...
- RMQ Message ACK
原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11808680.html 消息持久化机制 消息丢失了,需要将队列持久化,即将autoDelete设置成f ...
- Task1.PyTorch的基本概念
1.什么是Pytorch,为什么选择Pytroch? PyTorch的前身便是Torch,其底层和Torch框架一样,但是使用Python重新写了很多内容,不仅更加灵活,支持动态图,而且提供了Pyth ...
- SSM项目web.xml等配置文件中如何查找类的全路径名?
如题, web.xml,applicationContext.xml 等配置文件中,有时不会出现自动提示类的名字,这时如何查找类的全路径名,如下图所示: 1.鼠标右键单击菜单栏Navigate选项,选 ...
- Ubuntu系统安装两个tomcat
1:创建两个tomcat 2:在/etc下有个 profile 然后vim 编辑它 在 最下面加上这句话.这是两个tomcat的路径 #开启多个tomcat export CATALINA_BASE ...
- PKU P2411 Mondriaan's Dream
PKU P2411 Mondriaan's Dream 题目描述: Squares and rectangles fascinated the famous Dutch painter Piet Mo ...
- JS占位符替换
String.prototype.format = function() { if(arguments.length === 0) return this; var obj = arguments[0 ...