To Miss Our Children Time(dp)
To Miss Our Children Time
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 4502 Accepted Submission(s): 1224
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.
10 10 12 0
10 10 12 1
10 10 11 2
2
10 10 11 1
10 10 11 1
0
11
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
const int MAXN = ;
typedef long long LL;
struct Node{
int w, h, c, d;
void init(){
scanf("%d%d%d%d", &w, &h, &c, &d);
if(w > h){
swap(w, h);
}
}
friend bool operator < (Node a, Node b){
if(a.h != b.h)
return a.h < b.h;
if(a.w != b.w)
return a.w < b.w;
return a.d > b.d;
}
};
Node dt[MAXN];
LL dp[MAXN];
bool js(Node a, Node b){
if(b.d == && a.w < b.w && a.h < b.h)
return true;
else if(b.d == && a.w <= b.w && a.h <= b.h && (a.w < b.w || a.h < b.h))
return true;
else if(b.d == && a.w <= b.w && a.h <= b.h)
return true;
return false;
}
int main(){
int n;
while(~scanf("%d", &n), n){
for(int i = ; i < n; i++){
dt[i].init();
}
sort(dt, dt + n);
memset(dp, , sizeof(dp));
LL ans = ;
for(int i = ; i < n; i++){
dp[i] = dt[i].c;
for(int j = ; j < i; j++){
if(js(dt[j], dt[i]))
dp[i] = max(dp[i], dp[j] + dt[i].c);
}
ans = max(ans, dp[i]);
}
printf("%lld\n", ans);
}
return ;
}
To Miss Our Children Time(dp)的更多相关文章
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition)
暴力 A - Orchestra import java.io.*; import java.util.*; public class Main { public static void main(S ...
- WPF制作QQ列表(仿qq列表特效)
先看效果图:这个是折叠特效. 代码结构: model是我们的数据模型,定义了在列表显示的人物名称 图片 简介 . Resource是我们的图片资源 和 存储图片资源路径.名称 ...
- CF1249F Maximum Weight Subset
CF1249F Maximum Weight Subset 洛谷评测传送门 题目描述 You are given a tree, which consists of nn vertices. Reca ...
- 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:你只能把它放在 ...
- hdu 4960 Another OCD Patient(dp)
Another OCD Patient Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Ot ...
- POJ3107Godfather[树形DP 树的重心]
Godfather Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6121 Accepted: 2164 Descrip ...
- codeforces 484D D. Kindergarten(dp)
题目链接: D. Kindergarten time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 积木(DP)问题
问题:Do you remember our children time? When we are children, we are interesting in almost everything ...
随机推荐
- Leetcode:linked_list_cycle
一. 题目 给定一个链表.确定它是否有一个环.不使用额外的空间? 二. 分析 1. 空链表不成环 2. 一个节点自环 3. 一条链表完整成环 思路:使用两个指针,一个每次往前走2步,一 ...
- [Cycle.js] The Cycle.js principle: separating logic from effects
The guiding principle in Cycle.js is we want to separate logic from effects. This first part here wa ...
- 初探HTML
就在今天我抱着试一试的态度稍微看了下HTML5, 尝试着接触一点新知识, 虽然学的并不多, 但是还是异常的兴奋, 感觉有好多东西和之前的不一样了, 包括控件的创建和一些属性的设置等, 总之这些变化与改 ...
- 《第一行代码》学习笔记29-内容提供器Content Provider(2)
1.查询操作: if (cursor != null) { while (cusor.moveToNext()) { String column1 = cursor.getString(cursor. ...
- (转载)iOS 多媒体
音频:(音效.音乐) 在iOS中音频播放从形式上可以分为音效播放和音乐播放.前者主要指的是一些短音频播放,通常作为点缀音频,对于这类音频不需要进行进度.循环等控制.后者指的是一些较长的音频,通常是主音 ...
- NPOI导入导出Excel
.net mvc利用NPOI导入导出excel 注意:如何导出的提交方式ajax导出是失效的! 解决方案是:js处理l两个表单的提交 代码: 第一步. 在页面里面加入2个隐藏的iframe, 如下 ...
- mysql-cluster集群原理介绍和搭建步骤(四个data/sql节点) (转)
MySQL簇概述 MySQL簇是一种技术,该技术允许在无共享的系统中部署“内存中”数据库的簇.通过无共享体系结构,系统能够使用廉价的硬件,而且对软硬件无特殊要求.此外,由于每个组件有自己的内存和磁盘, ...
- uva11292贪心基础题目
C - 贪心 基础 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:65536KB 64bi ...
- 编译Boost 详细步骤
vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一. Boost库由C++标准委员会 ...
- C语言预处理指令的初步了解
所谓预处理是指在进行编译的第一遍扫描(词法扫描和语法分析)之前所作的工作.预处理是C语言的一个重要功能,它由预处理程序负责完成.当对一个源文件进行编译时,系统将自动引用预处理程序对源程序中的预处理部分 ...