제출 #344583

#제출 시각아이디문제언어결과실행 시간메모리
344583bachaquer은행 (IZhO14_bank)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
 
using namespace std;
 
ll n, x, m;
 
 
int main() {
    //freopen("divide.in", "r", stdin);
    //freopen("divide.out", "w", stdout);
    cin >> n >> m;
    vector<ll> v, vvv;
    for (int i = 0; i < n; i++) {
        cin >> x;
        v.pb(x);
    }
    for (int i = 0; i < m; i++) {
        cin >> x;
        vvv.pb(x);
    }
    bool tru = true;
    for (int i = 0; i < n; i++) {
        bool bar = false;
        for (int j = 0; j < m; j++) {
            x = v[i];
            for (int k = j; k < m; k++) {
                while (x - vvv[k] >= 0) x -= vvv[k];
                if (x == 0) {
                    bar = true;
                    break;
                }
            }
            if (bar) break;
        }
        if (bar == false) {
            tru = false;
            break;
        }
    }
    if (tru) cout << "YES";
    else cout << "NO";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...