#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define dim 100002
#define lim 1000000
#define mdim 1501
#define mult 2e9
#define maxx 200000
#define simaimult 1e17
#define piii pair<int,pair<int,int> >
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define nr_biti __builtin_popcount
using namespace std;
ifstream fin("bank.in");
ofstream fout("bank.out");
int n,m;
int a[22],b[22];
bool dp[1<<22][22];
vector<int> curr;
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(nullptr);
fout.tie(nullptr);
fin >> n >> m;
for(int i=1; i<=n; i++)
fin >> a[i];
for(int i=0; i<m; i++)
fin >> b[i];
for(int i=1; i<=n; i++)
{
if(i==1)
{
bool ok=0;
for(int j=1; j<(1<<m); j++)
{
int s=0;
for(int z=0; z<m; z++)
{
if(j&(1<<z))
{
s+=b[z];
}
}
if(s==a[1])
{
curr.pb(j);
ok=1;
}
}
if(!ok)
{
cout <<"NO";
return 0;
}
}
else
{
vector<int> temp;
for(int j=1; j<(1<<m); j++)
{
int s=0;
for(int z=0; z<m; z++)
{
if(j&(1<<z))
{
s+=b[z];
}
}
if(s==a[i])
{
for(auto it:curr)
{
bool okk=1;
for(int z=0; z<m; z++)
{
if(it&(1<<z) && j&(1<<z))
okk=0;
}
if(okk)
temp.pb(j|it);
}
}
}
curr=temp;
if(curr.empty())
{
fout <<"NO";
return 0;
}
}
}
fout << "YES";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |