显然塔的总高度不会超过最大的a[i],而a[i]之前的可以到达的高度

是由a值更小的块组成,所以按照a从小到大的顺序去转移。

然后就是多重背包判断存在性了,几乎和coin那题一样。

数据没coin丧病,倍增可过,单调队列也可,不过还是优化定义最好写。

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std; const int maxk = , maxh = 4e4+;
struct Block
{
int h, a, c;
bool operator <(const Block& th) const{
return a < th.a;
}
void IN(){ scanf("%d%d%d",&h,&a,&c); }
}B[maxk]; int f[maxh]; //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int k;
scanf("%d",&k);
for(int i = k; i--;) B[i].IN();
sort(B,B+k);
int ans = ;
memset(f+,-,sizeof(int)*B[k-].a);
for(int i = ; i < k; i++){
for(int j = ; j <= B[i].a; j++){
if(~f[j]) f[j] = B[i].c;
else if(j>=B[i].h && f[j-B[i].h] > ){
f[j] = f[j-B[i].h] - ;
ans = max(j,ans);
}else f[j] = -;
}
}
printf("%d\n",ans);
return ;
}

POJ 2392 Space Elevator(多重背包)的更多相关文章

  1. poj 2392 Space Elevator(多重背包+先排序)

    Description The cows are going to space! They plan to achieve orbit by building a sort of space elev ...

  2. POJ 2392 Space Elevator(多重背包变形)

    Q: 额外添加了最大高度限制, 需要根据 alt 对数据进行预处理么? A: 是的, 需要根据 alt 对数组排序 Description The cows are going to space! T ...

  3. POJ 2392 Space Elevator(贪心+多重背包)

    POJ 2392 Space Elevator(贪心+多重背包) http://poj.org/problem?id=2392 题意: 题意:给定n种积木.每种积木都有一个高度h[i],一个数量num ...

  4. POJ 2392 Space Elevator 背包题解

    多重背包.本题不须要二分优化.相对简单点.由于反复数十分小,小于10. 而添加一个限制每种材料的高度做法.假设使用逆向填表,那么仅仅须要从这个高度往小递归填表就能够了. 还有就是注意要排序,以限制高度 ...

  5. poj[2392]space elevator

    Description The cows are going to space! They plan to achieve orbit by building a sort of space elev ...

  6. poj2392 Space Elevator(多重背包)

    http://poj.org/problem?id=2392 题意: 有一群牛要上太空.他们计划建一个太空梯-----用一些石头垒.他们有K种不同类型的石头,每一种石头的高度为h_i,数量为c_i,并 ...

  7. POJ 2392 Space Elevator DP

    该题与POJ 1742的思路基本一致:http://www.cnblogs.com/sevenun/p/5442279.html(多重背包) 题意:给你n个电梯,第i个电梯高h[i],数量有c[i]个 ...

  8. POJ 2392 Space Elevator 贪心+dp

    题目链接: http://poj.org/problem?id=2392 题意: 给你k类方块,每类方块ci个,每类方块的高度为hi,现在要报所有的方块叠在一起,每类方块的任何一个部分都不能出现在ai ...

  9. poj 1742 Coins (多重背包)

    http://poj.org/problem?id=1742 n个硬币,面值分别是A1...An,对应的数量分别是C1....Cn.用这些硬币组合起来能得到多少种面值不超过m的方案. 多重背包,不过这 ...

随机推荐

  1. VS Code(待补充)

    使用! 然后Tab  快速生成html文档结构 快速生成一个类   .类名  会有提示 .container.box .col-6*2 VisualStudio Code怎么同时编辑多处?

  2. vue -- 使用sass并引入公共sass文件

    sass可以提高我们的开发效率,怎么在vue的项目中使用sass并且可以设置一些公共的文件呢? 使用sass 1.安装sass的依赖包 npm install --save-dev sass-load ...

  3. java知识点积累(一)

    知识点积累 1.关于final的重要知识点: final关键字可以用于成员变量.本地变量.方法以及类: final修饰的成员变量必须在声明时被初始化,或者在构造器中初始化,否则就会报编译错误: 不能够 ...

  4. 洛谷P1932 A+B A-B A*B A/B A%B Problem

    P1932 A+B A-B A*B A/B A%B Problem 题目背景 这个题目很新颖吧!!! 题目描述 求A.B的和差积商余! 由于数据有修改,减法运算结果可能带负号! 输入输出格式 输入格式 ...

  5. java 调用SAP RFC函数错误信息

    RFC接口调用SAP如果有异常会通过com.sap.mw.jco.JCO$Exception: 抛出异常 在开发中遇到的异常有如下 用户名密码可能是错误或者用户无权限,确认用户,必要时联系SAP负责人 ...

  6. Spring动态切换数据源

    11 //定义数据源枚举public enum DataSourceKey { master, slave, } 22 /** * 数据源路由 */ @Slf4j public class Dynam ...

  7. [USACO09OCT]热浪Heat Wave Dijkstra

    题目描述 The good folks in Texas are having a heatwave this summer. Their Texas Longhorn cows make for g ...

  8. B.Grid with Arrows-The 2019 ICPC China Shaanxi Provincial Programming Contest

    BaoBao has just found a grid with $n$ rows and $m$ columns in his left pocket, where the cell in the ...

  9. Swift几行代码解决UITableView空数据视图问题

    tableView空数据问题 一般项目中tableView若数据为空时会有一个提示示意图 为了更好的管理这种提示示意图,笔者利用extension进行了简单的拓展 解决思路 利用swift面向协议的特 ...

  10. C# DataTable转List<T>--利用反射

    /// <summary> /// 利用反射将Datatable转换为List<T>对象 /// </summary> /// <typeparam name ...