hdu 2602 大水01背包
来源:互联网 发布:快期交易软件 编辑:程序博客网 时间:2024/05/01 05:08
#include<cstdio>
#include<iostream>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<iomanip>
#include<set>
#include<string>
#include<iterator>
using namespace std;
int w[1100];
int v[1100];
int dp[1100];
int main(){
int N,V;
int T;
cin>>T;
while(T--){
cin>>N>>V;
for(int i=0;i<N;i++)
cin>>v[i];
for(int i=0;i<N;i++)
cin>>w[i];
memset(dp,0,sizeof(dp));
for(int i=0;i<N;i++)
for(int j=V;j>=w[i];j--)
dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
cout<<dp[V]<<endl;
}
}
#include<iostream>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<iomanip>
#include<set>
#include<string>
#include<iterator>
using namespace std;
int w[1100];
int v[1100];
int dp[1100];
int main(){
int N,V;
int T;
cin>>T;
while(T--){
cin>>N>>V;
for(int i=0;i<N;i++)
cin>>v[i];
for(int i=0;i<N;i++)
cin>>w[i];
memset(dp,0,sizeof(dp));
for(int i=0;i<N;i++)
for(int j=V;j>=w[i];j--)
dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
cout<<dp[V]<<endl;
}
}
- hdu 2602 大水01背包
- HDU 2602 01背包
- 01背包 HDU 2602
- HDU 2602 01背包
- hdu 2602 01背包
- hdu 2602 01背包
- hdu 2602 01背包
- hdu 4247 大水题
- hdu 4206 大水题
- hdu 2602 背包问题之01背包
- 刷背包之01背包- HDU 2602
- hdu 2602 01背包,hdu 1114 完全背包
- DP 01背包 hdu 2602
- hdu 2602 DP 01背包
- hdu 2602 01背包DP
- hdu 2602 (01背包)
- hdu 2602(01背包)
- hdu 2602(01背包)
- PHP 编码规范6.2 复合语句
- PHP 编码规范 6.3 返回语句
- 多线程 线程队列的实现
- C语言常犯错误总结
- PHP 编码规范 6.6 while语句
- hdu 2602 大水01背包
- 第七周项目一----静态成员的应用
- linux 自学笔记(十二)Shell编程
- PHP 编码规范 6.7 do...while语句
- S3C2440开发板LED驱动——ioremap 映射
- PHP 编码规范 6.8 switch语句
- 操作系统总结
- PHP 编码规范 6.9 try...catch语句
- NYOJ 28 大数阶乘