이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |