显示代码纯文本
#include<iostream>
#include<bitset>
using namespace std;
bitset<500010> s;
int t[210],n,m,ans[100010]={},k,a;
void c(int k2,int a2)
{
int t=1,x;
while(a2>=t)
{
x=k2*t;
s=s|s<<x;
a2-=t;
t=t*2;
}
if(a2>0)
{
x=k2*a2;
s=s|s<<x;
}
return;
}
int main()
{
freopen("noi_online2020_watch.in","r",stdin);
freopen("noi_online2020_watch.out","w",stdout);
s[0]=1;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>k>>a;
c(k,a);
}
for(int i=1;i<=m;i++)
{
int b;
cin>>b;
ans[i]=s[b];
}
for(int i=1;i<=m;i++)
{
if(ans[i]==1)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
return 0;
}