poj 4001 To Miss Our Children Time
To Miss Our Children Time
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 4740 Accepted Submission(s):
1319
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.
"Skyscraper"'s height using the n blocks.
10 10 12 0
10 10 12 1
10 10 11 2
2
10 10 11 1
10 10 11 1
0
11
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int N_MAX = + ;
ll dp[N_MAX];
int n;
struct Cube {
ll w, l,h;
int id;
bool operator <(const Cube&b) {
if (this->l != b.l)return this->l < b.l;
else if(this->w!=b.w) return this->w < b.w;
else return this->id > b.id;
}
}cube[N_MAX]; bool judge(const Cube& a,const Cube& b) {//b要堆在a上面
if (b.id == )return b.l >= a.l&&b.w >= a.w;
if (b.id == )return (b.l >= a.l&&b.w > a.w) || (b.l > a.l&&b.w >= a.w);
return b.l > a.l&&b.w > a.w;
} void Dp() {
for (int i = ; i < n;i++) {
dp[i] = cube[i].h;
}
for (int i = ; i < n;i++) {//每次cube[i]要堆在最上面
for (int j = ; j < i;j++) {
if (judge(cube[j], cube[i]))dp[i] = max(dp[i], dp[j] + cube[i].h);
}
}
ll sum = *max_element(dp, dp + n);
printf("%I64d\n",sum);
} int main() {
while (scanf("%d",&n)&&n) {
for (int i = ; i < n;i++) {
scanf("%I64d%I64d%I64d%d",&cube[i].l,&cube[i].w,&cube[i].h,&cube[i].id);
if (cube[i].l < cube[i].w)swap(cube[i].l, cube[i].w);
}
sort(cube, cube + n);
Dp();
}
return ;
}
poj 4001 To Miss Our Children Time的更多相关文章
- 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 ...
- HDU 4001 To Miss Our Children Time(2011年大连网络赛 A 贪心+dp)
开始还觉得是贪心呢... 给你三类积木叫你叠楼房,给你的每个积木包括四个值:长 宽(可以互换) 高 类型d d=0:你只能把它放在地上或者放在 长 宽 小于等于 自己的积木上面 d=1:你只能把它放在 ...
- poj 2438 Children's Dining
http://poj.org/problem?id=2438 题意: 有2*N个人要坐在一张圆桌上吃饭,有的人之间存在敌对关系,安排一个座位次序,使得敌对的人不相邻. 假设每个人最多有N-1个敌人.如 ...
- POJ 3083 -- Children of the Candy Corn(DFS+BFS)TLE
POJ 3083 -- Children of the Candy Corn(DFS+BFS) 题意: 给定一个迷宫,S是起点,E是终点,#是墙不可走,.可以走 1)先输出左转优先时,从S到E的步数 ...
- poj 3083 Children of the Candy Corn
点击打开链接 Children of the Candy Corn Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8288 ...
- Children of the Candy Corn 分类: POJ 2015-07-14 08:19 7人阅读 评论(0) 收藏
Children of the Candy Corn Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10933 Acce ...
- poj 3083 Children of the Candy Corn(DFS+BFS)
做了1天,总是各种错误,很无语 最后还是参考大神的方法 题目:http://poj.org/problem?id=3083 题意:从s到e找分别按照左侧优先和右侧优先的最短路径,和实际的最短路径 DF ...
- POJ 3083 Children of the Candy Corn bfs和dfs
Children of the Candy Corn Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8102 Acc ...
- POJ:3083 Children of the Candy Corn(bfs+dfs)
http://poj.org/problem?id=3083 Description The cornfield maze is a popular Halloween treat. Visitors ...
随机推荐
- Oracle 函数使用记录
持续更新…… 参考:https://www.cnblogs.com/bbliutao/archive/2017/11/08/7804263.html 1. ADD_MONTHS 语法: ADD_MON ...
- 01_7_Struts_用Action的属性接收参数
01_7_Struts_用Action的属性接收参数 1. 配置struts.xml文件 <package name="user" namespace="/user ...
- java子父类初始化顺序 (1)父类静态代码块(2)父类静态变量初始化(3)子类静态代码块(4)子类静态变量初始化(5)main(6)有对象开辟空间都为0(7)父类显示初始化(8)父类构造(9)子类显示初始化(10)子类构造
标题 静态代码块与静态成员变量还要看代码的先后顺序 看程序,说出结果 结果为: x=0 看程序,说出结果 结果如下: 补充 : 静态代码块:static{ } 在JVM加载时即执行,先于主方法执行,用 ...
- php过滤html标签
<?php function kill_html($str){ //清除HTML标签 $st=-1; //开始 $et=-1; //结束 $stmp=array(); $stmp[]=" ...
- Ubuntu 16.04中安装谷歌Chrome浏览器
1.进入 Ubuntu 16.04 桌面,按下 Ctrl + Alt + t 键盘组合键,启动终端. 2.在终端中,输入以下命令: sudo wget https://repo.fdzh.org/ch ...
- LeetCode(226)Invert Binary Tree
题目 分析 交换二叉树的左右子树. 递归非递归两种方法实现. AC代码 class Solution { public: //递归实现 TreeNode* invertTree(TreeNode* r ...
- POJ:2632-Crashing Robots
Crashing Robots Time Limit: 1000MS Memory Limit: 65536K Description In a modernized warehouse, robot ...
- 15年多校第一场七题hdu5294
要做这题,先要明白图的割,说白了就是 为了让原点无法到汇点要删几条边(之所以叫割,就是在图面上切一刀,减掉最小的边是原点和汇点成为两个集合),想到了割先放着一会用. 题中说只有沿最短路走才有可能追上, ...
- hdu2604 递推转换矩阵快速幂
刚开始还以为用位运算与或几下几个循环就搞定了,算着算着发现不行........ 还是一种固定的切题角度,我假设有长度为n,总的排列数位f(n),怎么算他呢?从后往前考虑,因为大多数情况,都是用前面的结 ...
- (转)React 入门实例教程
作者: 阮一峰 现在最热门的前端框架,毫无疑问是 React . 上周,基于 React 的 React Native 发布,结果一天之内,就获得了 5000 颗星,受瞩目程度可见一斑. React ...