POJ 2392 DP
来源:互联网 发布:社团团徽设计软件 编辑:程序博客网 时间:2024/05/14 17:21
题目大意:有一头奶牛要上太空,他有很多种石头,每种石头的高度是hi,但是不能放到ai之上的高度,并且这种石头有ci个
将这些石头叠加起来,问能够达到的最高高度。
题意转载自:http://blog.csdn.net/wangjian8006/article/details/7607745
思路:
按a[i]排个序,多重背包。
// by SiriusRen#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int k,f[40150];struct node{int h,a,c;}s[401];bool cmp(node a,node b){return a.a<b.a;}int main(){ scanf("%d",&k); for(int i=1;i<=k;i++) scanf("%d%d%d",&s[i].h,&s[i].a,&s[i].c); memset(f,0x3f,sizeof(f)),f[0]=0; sort(s+1,s+1+k,cmp); for(int i=1;i<=k;i++){ for(int j=0;j<=s[i].a-s[i].h;j++) if(f[j]!=0x3f3f3f3f&&f[j]<s[i].c) f[j+s[i].h]=min(f[j]+1,f[j+s[i].h]); for(int j=0;j<=s[i].a;j++)if(f[j]!=0x3f3f3f3f)f[j]=0; } for(int i=40100;i>=0;i--) if(f[i]!=0x3f3f3f3f){printf("%d\n",i);break;}}
0 0
- poj 2392 DP
- Poj 2392(dp)
- POJ 2392 DP
- poj dp
- 【dp】POJ
- 【dp】POJ
- [DP] POJ
- [DP] POJ
- [DP] POJ
- 【dp】POJ
- POJ 2392 Space Elevator [DP 多重背包]
- POJ 2392 Space Elevator (dp)
- poj 动态规划DP - 2392 Space Elevator
- poj 2392 Space Elevator dp 多重背包
- POJ 2392 简单dp 多重背包
- poj 2392 dp 不是很懂哎!!!Space Elevator
- POJ 3670 && POJ 3671 (dp)
- 【DP】 POJ 1080
- PyGobject(四十五)布局容器之Grid
- HDU 5705(思路题)
- Oracle 11g数据库安装及配置
- 静态内存分配-链表管理(1)单向量表讲解
- Android studio code template个性化设置
- POJ 2392 DP
- Just a Hook(就是一个 set(线段树))
- 选择排序
- Redhat下载地址
- Loadrunner结果文件太大打不开
- mac 下安装react native
- HDU 4840(最小生成树)
- 设计模式概述
- PyGobject(四十六)布局容器之Fixed