# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
361583 | shahriarkhan | Bank (IZhO14_bank) | C++14 | 1091 ms | 3240 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] ;
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) ;
}
}
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 ;
dp2.push_back(j|k) ;
}
}
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... |