제출 #856467

#제출 시각아이디문제언어결과실행 시간메모리
856467yash_9a3b은행 (IZhO14_bank)C++17
0 / 100
1 ms452 KiB
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define endl '\n'
#define int long long
#define f first
#define mp make_pair
#define s second
using namespace std;

int n, m;
int p[20], b[20];

signed main()
{
    fast;
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < m; i++) cin >> b[i];
    bool ans = false;
    for(int msk = 0; msk < (1 << m); msk++){
        int add = 0;
        for(int i = 0; i < n; i++) if(msk & (1 << i)) add += b[i];
        if(add == p[0]) ans = true;
    }
    cout << (ans ? "YES" : "NO") << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...