POJ 3624 01背包
来源:互联网 发布:淘宝客服能在家里做吗 编辑:程序博客网 时间:2024/06/06 01:44
如题http://poj.org/problem?id=3624
最基础的01背包
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define MAXN 3500
#define MAXV 13000
#define max(a,b)(a>b?a:b)
int N,M;
int c[MAXN];
int w[MAXN];
int f[MAXV];
int main()
{
scanf("%d%d",&N,&M);
int i,j;
for(i=1;i<=N;i++)
scanf("%d%d",&c[i],&w[i]);
memset(f,0,sizeof(f));
for(i=1;i<=N;i++)
for(j=M;j>=c[i];j--)
f[j]=max(f[j],f[j-c[i]]+w[i]);
printf("%d\n",f[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背包与完全背包
- poj 2513 Colored Sticks
- 用python写的多线程网页爬虫
- tar、tar.gz、tar.bz2的区别与用法
- MATLAB学习笔记(二):符号计算(创建符号对象)
- Socket通信基础——基于TCP的用户登录
- POJ 3624 01背包
- centos mysql安装
- Lexicographically minimum string rotation
- JavaScript系列二:变量、数组、流程控制、函数以及事件响应
- 1501171340-蓝桥杯-算法提高 逆序排列
- microsoftoffice2013 破解方法(含有破解工具)
- [leetcode] Valid Parentheses
- Spark的核心概念
- (KVM连载)3.4 编译qemu-kvm和安装qemu-kvm