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个敌人的位置,你一枪能杀两个,可 ...
随机推荐
- Bootstrap框架如何设置导入链接
bootstrap文件划分: 导入规则: 方式一:可以先下载 ----https://v3.bootcss.com/ (1) 注意事项: (2) (3) 注意1:bootstrap中的js文件依赖于j ...
- GB28181 To RTMP/HLS/HTTP-FLV/DASH Gateway
I. Deployment / Architecture Block Diagram II. Resources Used 1. freeswitch —— sip server https://f ...
- linux创建相关待同步目录
[root@rsync-server-1 ~]# mkdir /data/{web,web_data}/redhat.sx -p [root@rsync-server-1 ~]# tree /data ...
- rabbit-c编译 vs2013
需要openssl的库
- 《Tomcat权威指南》读书笔记
第一章 Tomcat的开幕式 1.Tomcat是以Java编写的,这表示在能够构建和测试它之前,必须安装最新的.完整的JAVA运行环境(JRE,Java runtime). 2.Catalina To ...
- Python---基础----数据类型的内置函数(主要介绍字符串、列表、元组、字典、集合的内置函数)(二)
2019-05-24 -------------------------------- 一. # splitlines() 以换行切割字符串s = '''日照香炉生紫烟\n疑是银河落九天\n飞流 ...
- 使用Fabric在tomcat中部署应用的问题总结
关闭tomcat时 A.为什么调用shutdown时,报错连接拒绝 结论——很可能是因为tomcat没启动或没完全启动:而这个时候调用shutdown就会出现此类报错 解决方法:time.sleep ...
- Flutter中的浮动按钮 FloatingActionButton
FloatingActionButton 简称 FAB ,可以实现浮动按钮,也可以实现类似闲鱼 app 的底部凸起导航 . 常用属性 FloatingActionButton的常用属性,同flutte ...
- 学习日记10、easyui编辑器combobox绑定数据的两种方式
1.数据本地绑定 var card = [{ "value": "正常", "text": "正常" }, { &quo ...
- 多行文本溢出隐藏处理,兼容ie,火狐
问题 多行文本溢出隐藏,webkit内核浏览器如谷歌支持如下写法: overflow: hidden; text-overflow: ellipsis; display: -webkit-box; - ...