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个敌人的位置,你一枪能杀两个,可 ...
随机推荐
- 【vue】父子组件间通信----传函数
(一)子组件 调用 父组件 方法 方式一) 子组件中通过this.$parent.event来调用父组件的方法 父组件 <template> <div> <child&g ...
- netcore中使用session
- Python2 安装教程
目录 1. 推荐阅读 2. 安装包下载 3. 安装步骤 1. 推荐阅读 Python基础入门一文通 | Python2 与Python3及VSCode下载和安装.PyCharm破解与安装.Python ...
- linux命令之 repeat 重复执行命令
$ vim ~/.bashrc function repeat() { number=$1 shift echo $@ for n in $(seq $number); do $@ done } $ ...
- flask之视图函数从前端接收数据的方法
一:从前端接收查询字符串 query-string 注意:get和post都可以在url后面添加查询字符串?a=1&b=2 测试工具:postman 1:get方式接收 视图函数 from ...
- C++ decltype
#include <iostream> using namespace std; int main() { int ia{3}; decltype(ia) varr[3]={1,2,3}; ...
- JavaWeb(七):EL表达式、自定义标签和JSTL
一.EL表达式 语法 el.jsp <%@page import="java.util.Date"%> <%@page import="com.atgu ...
- 监听UDP端口
功能:监听服务器的UDP端口,输出端口接收的数据 #encoding:utf-8 import socket global udp global ip global port def listen_p ...
- 历时小半年总结之JAVA
一.JavaSE 1.多线程 (1).进程与线程的区别? 答:进程是所有线程的集合,每一个线程是进程中的一条执行路径,线程只是一条执行路径. (2).为什么要用多线程? 答:提高程序效率 (3).多线 ...
- String reduction (poj 3401
String reduction Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1360 Accepted: 447 D ...