标签:
#include <cstdio> #include <cstring> using namespace std; const int M = 100005; const int N = 105; int d[M]; int n,a[N],c[N],m; void solve() { memset(d, -1, sizeof(d)); d[0] = 0; for(int i = 0; i < n; i++) { for(int j = 0; j <= m; j++) { if(d[j] >= 0) d[j] = c[i]; else if(j < a[i] || d[j-a[i]]<= 0) d[j] = -1; else d[j] = d[j-a[i]]-1; } } int ans = 0; for(int i = 1; i <= m; i++) if(d[i]>=0) ans++; printf("%d\n", ans); } int main() { //freopen("in.txt", "r", stdin); while(~scanf("%d %d", &n, &m) &&(n||m)) { for(int i = 0; i < n; i++) scanf("%d", a+i); for(int i = 0; i < n; i++) scanf("%d", c+i); solve(); } return 0; }
标签:
原文地址:http://www.cnblogs.com/sevenun/p/5442279.html