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个敌人的位置,你一枪能杀两个,可 ...
随机推荐
- centos 搭建svn服务器
1 安装svnserve yum install subversion -y 2 创建仓库 mkdir /svn/rep1 -p mkdir /svn/rep2 -p svnadmin create ...
- SpringBoot application.proerties基本配置
#设置日志输出路径,日志文件名称,输出日志级别 默认日志文件超过10M会切分成多个文件 最新的日志文件就是设置的日志文件 logging.level.root=INFOlogging.level.or ...
- python tkinter坐标转换
tkinter中坐标原点在左上角,横坐标向右,纵坐标向下,画图需要将坐标转换成右下角的某个点来符合我们的常用坐标 坐标原点设为(x0,y0),横坐标向右,纵坐标向上,: 转换:想实现坐标点(x,y)的 ...
- Redis基础系列-安装启动
安装 ①将Redis 的tar 包上传到opt 目录②解压缩③安装gcc 环境我们需要将源码编译后再安装,因此需要安装c 语言的编译环境!不能直接make! 可以上网,yum install –y g ...
- LeetCode--044--通配符匹配(java)*
给定一个字符串 (s) 和一个字符模式 (p) ,实现一个支持 '?' 和 '*' 的通配符匹配. '?' 可以匹配任何单个字符. '*' 可以匹配任意字符串(包括空字符串). 两个字符串完全匹配才算 ...
- git怎样删除未监视的文件untracked files ?
git怎样删除未监视的文件untracked files 需要添加到.gitignore文件 # 删除 untracked files git clean -f # 连 untracked 的目录也一 ...
- [CF846C]Four Segments题解
我们暴力枚举一下\(delim_{1}\) 然后对于每个\(delim_{1}\),O(n)扫一遍+前缀和求出最大\(delim_{0}\)和\(delim_{2}\),然后记录一下它们的位置就行啦 ...
- Linux下安装Harbor 1.8.0 仓库的安装和使用(亲测)
根据Harbor官方描述: Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全.标识和管理等,扩展了开源Docker Distri ...
- Win10真正好用之处
第一步. 关闭无用服务 刚装好Win10的时候,整部电脑响应很慢,有时什么都不做,硬盘灯也能狂闪半天.很明显,这是微软爸爸默认开启的服务未被及时关闭所致. 网上有很多文章指导新手如何关闭系统服务,但 ...
- [CSP-S模拟测试]:Seat(概率DP+数学)
题目描述 有$n+2$个座位等距地排成一排,从左到右编号为$0$至$n+1$.最开始时$0$号以及$n+1$号座位上已经坐了一个小$G$,接下来会有$n$个小$G$依次找一个空座位坐下.由于小$G$们 ...