poj 3624 01背包
来源:互联网 发布:知聊能不能提现 编辑:程序博客网 时间:2024/06/06 01:11
http://poj.org/problem?id=3624
主要注意的是内存的优化
以下是我的代码
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int sizen=14000;
int dp[sizen];
struct ele
{
int w;
int d;
}p[4000];
int main()
{
int n,m;
int i,j;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(i=1;i<=n;i++)
scanf("%d%d",&p[i].w,&p[i].d);
memset(dp,0,sizeof(dp));
for(i=1;i<=n;i++)
for(j=m;j>=1;j--)
if(j>=p[i].w)
dp[j]=max(dp[j],dp[j-p[i].w]+p[i].d);
else
dp[j]=dp[j];
printf("%d\n",dp[m]);
}
return 0;
}
0 0
- 01 背包 poj 3624
- poj 3624 01背包
- poj 3624 01 背包
- poj 3624 01背包
- poj 3624 01背包
- POJ 3624 01背包
- POJ-3624 01背包
- poj 3624(01背包)
- poj 3624 01背包
- POJ-3624-01背包
- 01背包问题 poj 3624
- POJ 3624 01背包问题
- poj 3624 dp-01背包
- POJ 3624 还是01背包
- poj 3624 01背包 水
- POJ 3624 01背包(DP)
- 【POJ 3624】 + 01背包 + dp
- POJ 3628 Bookshelf2 / POJ 3624 Charm Bracelet / POJ 1384 初涉01背包与完全背包
- Hibernate调用Oracle的存储过程
- 让eclipse自动生成的注释的时间显示英文,不用中文.
- 解决Linux磁盘空间满的“软”办法
- 香港怎么了
- 使用Qt编写模块化插件式应用程序
- poj 3624 01背包
- sshfs Input/output error
- cuda学习笔记
- Android Fragment应用实战,使用碎片向ActivityGroup说再见
- 苹果要求所有新app以及版本更新必须支持iOS 8 SDK和64-bit
- HDU1176_免费馅饼【数塔】
- Linux操作系统下/etc/hosts文件配置方法
- inflate()和findViewById()
- qqqq