Submission #1004055

#TimeUsernameProblemLanguageResultExecution timeMemory
1004055LuvidiBank (IZhO14_bank)C++17
71 / 100
557 ms262148 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define fs first #define sc second #define pb push_back void solve() { int n,m; cin>>n>>m; int a[n],b[m]; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<m;i++)cin>>b[i]; vector<int> ma[20001]; for(int m1=0;m1<(1<<m);m1++){ int s=0; for(int i=0;i<m;i++){ if(m1&(1<<i))s+=b[i]; } ma[s].pb(m1); } vector<int> v; v.pb(0); for(int i=0;i<n;i++){ vector<int> v2; for(int m1:v){ for(int m2:ma[a[i]]){ if((m1&m2)==0){ v2.pb(m1^m2); } } } v=v2; } if(!v.empty())cout<<"YES"; else cout<<"NO"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...