poj 3211 背包
来源:互联网 发布:圈子 知乎 编辑:程序博客网 时间:2024/06/02 03:49
#include<stdio.h>#include<string.h>#define MAX(x,y) ((x)>(y)?(x):(y))int w[12][120],num[12],sum[12];int dp[11000];int main(){char s2[100][100],s1[100];int n,m,x;while(~scanf("%d%d",&n,&m)&&(n+m)){memset(num,0,sizeof(num));memset(sum,0,sizeof(sum));for(int i=0;i<n;i++)scanf("%s",s2[i]);for(int i=0;i<m;i++){scanf("%d %s",&x,s1);for(int j=0;j<n;j++){if(strcmp(s2[j],s1)==0){w[j][num[j]]=x;num[j]++;sum[j]+=x; break; }}}int res=0;for(int i=0;i<n;i++){memset(dp,0,sizeof(dp));int col=sum[i]/2;for(int j=0;j<num[i];j++){for(int k=col;k>=w[i][j];k--)dp[k]=MAX(dp[k],dp[k-w[i][j]]+w[i][j]);}res+=(sum[i]-dp[col]);}printf("%d\n",res); }}
0 0
- poj-3211-01背包
- poj 3211 01 背包
- poj 3211 背包
- poj 3211 01背包问题
- poj 3211 Washing Clothes(背包)
- POJ 背包
- POJ 3211 Washing Clothes (分组背包+0/1背包)
- POJ 3211 Washing Clothes【01背包】
- poj 3211 Washing Clothes(01背包问题)
- POJ 3211 Washing Clothes【01背包+STL】
- poj 3211 Washing Clothes(01背包)
- poj 3211 Washing Clothes(0/1背包)
- poj 3211 Washing Clothes 01背包
- poj 3211 Washing Clothes 01背包
- POJ 3211 Washing Clothes (0/1背包)
- poj 3211 Washing Clothes 01背包问题
- POJ 3211 Washing Clothes 0-1背包
- poj 3211 Washing Clothes 分组01背包
- 安装e(fx)clipse到Eclipse (JavaFX工具)
- JavaFX概述和简介
- JavaFX开发环境安装配置
- python实现费波纳茨数列——递归、迭代
- 在Eclipse安装JavaFX Scene Builder
- poj 3211 背包
- 在Eclipse安装JavaFX Scene Builder
- A.1输入长方形的两边长a和b,输出长方形的周长和面积
- 用cxf生成webservice的java客户端代码
- 即将交稿新书《SSM和Redis实现》,欢迎大家关注
- CPU卡程序设计实例(一)电路
- ubuntu 17.04 install openssl
- 揭秘Kafka高性能架构之道-Kafka设计解析(六)
- CPU卡程序设计实例(二)软件设计