谔谔,4和5被卡了,只拿了30,但是为什么WA了啊
#include<bits/stdc++.h>
using namespace std;
int n,m,k,a,t;
map<int,int> dp;
int main()
{
//freopen("watch.in","r",stdin);
//freopen("watch.out","w",stdout);
cin >> n >> m;
dp[0]=1;
for(int i=1;i<=n;i++)
{
cin >> a >> k;
if(n<=10) k=min(k,250/a);
else k=min(k,500000/a);
for(int i=1;i<=k;i++)
for(int j=n<=10?250:500000;j>=a;j--)
dp[j]=dp[j]||dp[j-a];
}
dp[0]=0;
for(int i=1;i<=m;i++)
{
cin >> t;
if(dp[t]) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}