poj 3211 01 背包
来源:互联网 发布:2010江苏高考数学知乎 编辑:程序博客网 时间:2024/06/09 19:24
#include<stdio.h>#include<string.h>int m,n;char str[15][15];int col[110][22];bool dp[200000];int t[110],s[110],g[110][110];int getid(char *s){for(int i=0;i<m;i++)if(strcmp(s,str[i])==0) return i;return 0;}int main(){ int i,j,k; char tmp[15]; while(scanf("%d%d",&m,&n)!=EOF) { if(n==0&&m==0) break; for(i=0;i<m;i++)scanf("%s",str[i]),t[i]=s[i]=0; for(i=0;i<n;i++) { scanf("%d%s",&k,tmp); s[j=getid(tmp)]+=k; g[j][t[j]++]=k; } int ans; for(ans=k=0;k<m;k++) { for(i=0;i<=s[k]/2;i++) dp[i]=0; dp[0]=1; for(i=0;i<t[k];i++) for(j=s[k]/2;j>=g[k][i];j--) if(dp[j-g[k][i]]) dp[j]=1; for(i=s[k]/2;i>=0;i--) if(dp[i]) break; ans+=s[k]-i; } printf("%d\n",ans); } return 0;}
- poj-3211-01背包
- poj 3211 01 背包
- poj 3211 01背包问题
- 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 01背包
- poj 3211 Washing Clothes 01背包
- poj 3211 Washing Clothes 01背包问题
- poj 3211 Washing Clothes 分组01背包
- POJ 3211Washing Clothes(01背包)
- Washing Clothes - POJ 3211 01背包
- POJ 3211 Washing Clothes(01背包)
- POJ 3211 - Washing Clothes(01背包)
- poj 3211 Washing Clothes 01背包
- POJ 3211 washing clothes (01背包)
- Washing Clothes poj 3211(01背包)
- hdu 3062 2-sat 水题
- poj 3678 2-sat 建图非常容易错!!
- hdu 1423 最长公共上升子序列
- poj 3624 01背包
- poj 3628 01背包
- poj 3211 01 背包
- poj 1745 dp
- 多校第一场
- poj 1837 01背包
- poj 1948 二维01背包
- poj 1976 dp
- hdu 1824 2-sat
- hdu 1203 01背包
- hdu 2955 Robberies 01背包