| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 91101 | Aydarov03 | Bank (IZhO14_bank) | C++14 | 84 ms | 7932 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 <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;
int a[25] , b[25];
vector <int> v[20005];
bool us[25];
int n , m;
void rec( int id = 1 , int OR = 0)
{
    for(auto c : v[ a[id] ] )
    {
        if( (c & OR) == 0 )
        {
            if( id == n )
            {
                puts("YES");
                exit(0);
            }
            rec( id+1 , OR | c );
        }
    }
}
main()
{
    scanf("%d%d" , &n , &m);
    for(int i = 1; i <= n; i++)
        scanf("%d" , &a[i]);
    for(int i = 1; i <= m; i++)
        scanf("%d" , &b[i]);
    if( n == m )
    {
        for(int i = 1; i <= n; i++)
        {
            bool ok = false;
            for(int j = 1; j <= m; j++)
            {
                if( !us[j] && a[i] == b[i] )
                {
                    us[j] = 1;
                    ok = 1;
                    break;
                }
            }
            if( !ok )
            {
                    puts("NO");
                    return 0;
            }
        }
        puts("YES");
        return 0;
    }
    for(int mask = 1; mask < (1<<m); mask++)
    {
        int sum = 0;
        for(int i = 0; i < m; i++)
        {
            if( mask & ( (1<<i) ) )
                sum += b[i+1];
        }
        v[sum].push_back( mask );
    }
    for(int i = 1; i <= n; i++)
    {
        if( v[a[i]].size() == 0 )
        {
            puts("NO");
            return 0;
        }
    }
    rec();
    puts("NO");
}
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... | ||||
