bitset 模拟 01背包。
#include <iostream>
#include <bitset>
using namespace std;
const int N=200100;
const int M=20;
bitset<N> b;
int m[M],x[M];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,i,j;
cin>>n;
for(i=1;i<=n;++i)
cin>>m[i];
for(i=1;i<=n;++i)
cin>>x[i];
b[0]=1;
for(i=1;i<=n;++i)
for(j=1;j<=x[i];++j)
b|=b<<m[i];
cout<<b.count();
return 0;
}