POJ 2392 Space Elevator
来源:互联网 发布:奥迪工程师编程教程 编辑:程序博客网 时间:2024/06/05 18:55
#include<stdio.h>#include<string.h>#include<stack>#include<string>#include<math.h>#include<queue>#include<set>#include<algorithm>#include<iostream>#include<vector>#include<map>using namespace std;#define LL long long#define inf 1<<31#define mod 1000000007#define N 40100int dp[N];struct node{ int x,y,z;}a[N],b[N];bool cmp(node c,node d){ return c.y<d.y;}int main(){ int i,j,n,m=0; scanf("%d",&n); memset(dp,0,sizeof(dp)); for(i=1;i<=n;i++) { scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z); m=max(m,a[i].y); } int tot=0; for(i=1;i<=n;i++)//多重背包转化为01背包 { int k=1; while(a[i].z>=k) { b[++tot].x=a[i].x*k; b[tot].y=a[i].y; a[i].z-=k; k<<=1; } if(a[i].z) { b[++tot].x=a[i].x*a[i].z; b[tot].y=a[i].y; } } sort(b+1,b+1+tot,cmp); for(i=1;i<=tot;i++) { for(j=b[i].y;j>=b[i].x;j--) dp[j]=max(dp[j],dp[j-b[i].x]+b[i].x); } int ans=0; for(i=m;i>=0;i--) ans=max(ans,dp[i]); printf("%d\n",ans); return 0;}
0 0
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- POJ-2392-Space Elevator
- poj 2392 Space Elevator
- poj 2392--Space Elevator
- poj 2392 Space Elevator
- POJ 2392 Space Elevator
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- poj 2392 Space Elevator
- poj 2392 space elevator
- POJ 2392 Space Elevator
- POJ 2392 Space Elevator
- POJ 2392 Space Elevator
- oracle 数据恢复
- Java Collection
- android网络编程之——客户端上传信息的代码
- LeetCode:Reverse Bits
- ios 中 set get 方法 便利构造器的创建 Block 动画
- POJ 2392 Space Elevator
- C#关键字的使用(params、explicit、implicit、operator)
- Android系统容量检测 —— Environment 和StatFs
- [LeetCode] 3Sum
- 平台无关性与语言无关性
- myeclipse 8.5 struts2 搭建成功后,相关问题。
- Factorial Trailing Zeroes
- 简单工厂的原理以及一个样例
- 什么时候使用runloop 以及 performSelector 具体使用方法