标签:training gre search 其他 bottom 记录 不同 memset center
3 10 1 2 4 2 1 1 2 5 1 4 2 1 0 0
8 4
#include <cstdio>
#include <cstring>
int const MAXM = 1e5 + 5;
int const MAXN = 1e2 + 5;
bool dp[MAXM];
int cnt[MAXM];
int a[MAXN], c[MAXN];
int main()
{
int n, m;
while(scanf("%d %d", &n, &m) != EOF && (n + m))
{
memset(dp, false, sizeof(dp));
for(int i = 1; i <= n; i ++)
scanf("%d", &a[i]);
for(int i = 1; i <= n; i ++)
scanf("%d", &c[i]);
dp[0] = true;
int ans = 0;
for(int i = 1; i <= n; i ++)
{
memset(cnt, 0, sizeof(cnt));
for(int s = a[i]; s <= m; s ++)
{
if(!dp[s] && dp[s - a[i]] && cnt[s - a[i]] < c[i])
{
dp[s] = true;
ans ++;
cnt[s] = cnt[s - a[i]] + 1;
}
}
}
printf("%d\n", ans);
}
}标签:training gre search 其他 bottom 记录 不同 memset center
原文地址:http://www.cnblogs.com/liguangsunls/p/7040444.html