poj 2392 Space Elevator (多重背包)
来源:互联网 发布:php源码下载 双轨制 编辑:程序博客网 时间:2024/05/09 19:17
Space Elevator
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8110 Accepted: 3843
题目大意 :一群牛要上天 用一些石块堆塔 给出石块的种类 及其每个种类的数量 和该种石块能出现的最高高度 和每种石块的数量
求怎么摆放才能堆得最高
多重背包模板题。。。。
将所有石块排序 把高度低的放下面
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct Class{ int h,maxh,c;}a[405];int cmp(Class x,Class y){ return x.maxh<y.maxh;}int main(){ int n,ans,i,j,dp[40005],sum[40005]; while(cin>>n) { for( i=0;i<n;i++) cin>>a[i].h>>a[i].maxh>>a[i].c; sort(a,a+n,cmp); memset(dp,0,sizeof(dp)); dp[0]=1; int ans=0; for(i=0;i<n;i++) { memset(sum,0,sizeof(sum)); for(j=a[i].h;j<=a[i].maxh;j++) { if(!dp[j]&&dp[j-a[i].h]&&sum[j-a[i].h]<a[i].c) { dp[j]=1; sum[j]=sum[j-a[i].h]+1;//统计石块放置的个数 if(ans<j) ans=j; } } } cout<<ans<<endl; } return 0;}
2 0
- POJ 2392 Space Elevator (多重背包)
- poj 2392 Space Elevator (多重背包)
- POJ 2392-Space Elevator(多重背包)
- poj Space Elevator 2392 (多重背包)
- POJ 2392 Space Elevator(多重背包)
- Space Elevator poj 2392(多重背包)
- POJ 2392 Space Elevator(多重背包)
- POJ - 2392 Space Elevator(多重背包)
- poj 2392 Space Elevator(多重背包)
- poj 2392 Space Elevator 多重背包
- poj 2392 Space Elevator(多重背包变形)
- POJ 2392 Space Elevator [DP 多重背包]
- poj 2392 Space Elevator(排序+多重背包)
- POJ 2392 Space Elevator (多重背包问题)
- POJ 2392 Space Elevator 多重背包
- POJ 2392 Space Elevator (多重背包+优化)
- poj 2392 Space Elevator (多重背包)
- poj 2392 Space Elevator(多重背包)
- jquery入门
- OSGI学习系列(四)类的加载
- Matlab 绘图特殊标注
- cocos2dx box2d 概念
- 细说Android事件传递机制(dispatchTouchEvent、onInterceptTouchEvent、onTouchEvent)
- poj 2392 Space Elevator (多重背包)
- HDOJ 1012 u Calculate e
- spring技术内幕14-Spring读取和处理事务配置
- oracle判断是否包含字符串的方法
- back键
- UIScroview 部分翻译
- 各大牛逼网站推荐系统
- sqlplus spool 使用
- 计算机视觉领域国际著名研究机构