제출 #732082

#제출 시각아이디문제언어결과실행 시간메모리
732082raul2008487은행 (IZhO14_bank)C++17
19 / 100
48 ms8680 KiB
#include <bits/stdc++.h>
#define pb push_back
#define in insert
#define ll long long
#define pll pair<ll,ll>
#define vpl vector<pll>
#define vl vector<ll>
#define sl set<ll>
#define msl multiset<ll>
#define mll map<ll,ll>
#define mmll multimap<ll,ll>
#define mcl map<char,ll>
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define endl "\n"
#define LMX LLONG_MAX
using namespace std;
//priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<ll,ll>> pq;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    sl s;
    ll n,m,i,j;
    cin>>n>>m;
    vl a(n),b(m),p;
    p.pb(0);
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<m;i++){
        cin>>b[i];
        ll sz=p.size();
        for(j=0;j<sz;j++){
            s.in(p[j]+b[i]);
            p.pb(p[j]+b[i]);
        }
    }
    /*for(auto x: s){
        cout<<x<<' ';
    }cout<<endl;*/
    if(s.count(a[0])){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"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...