# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
361584 | shahriarkhan | Bank (IZhO14_bank) | C++14 | 434 ms | 89156 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std ;
int main()
{
int n , m ;
scanf("%d%d",&n,&m) ;
int a[n+1] , b[m+1] , vis[n+1][1<<m] ;
for(int i = 1 ; i <= n ; ++i) scanf("%d",&a[i]) ;
for(int i = 1 ; i <= m ; ++i) scanf("%d",&b[i]) ;
vector<int> pos[n+1] , dp ;
for(int i = 1 ; i < (1<<m) ; ++i)
{
int sum = 0 ;
for(int j = 0 ; j < m ; ++j)
{
if(i&(1<<j)) sum += b[j+1] ;
}
for(int j = 1 ; j <= n ; ++j)
{
if(a[j]==sum) pos[j].push_back(i) ;
}
}
for(int i = 0 ; i <= n ; ++i)
{
for(int j = 0 ; j < (1<<m) ; ++j)
{
vis[i][j] = 0 ;
}
}
dp.push_back(0) ;
for(int i = 1 ; i <= n ; ++i)
{
vector<int> dp2 ;
for(int j : dp)
{
for(int k : pos[i])
{
if(j&k) continue ;
if(!vis[i][j|k])
{
dp2.push_back(j|k) ;
vis[i][j|k] = 1 ;
}
}
}
dp = dp2 ;
if(dp.empty())
{
puts("NO") ;
return 0 ;
}
}
puts("YES") ;
return 0 ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |