제출 #413920

#제출 시각아이디문제언어결과실행 시간메모리
413920bigDuck은행 (IZhO14_bank)C++14
71 / 100
1093 ms3072 KiB
#include<bits/stdc++.h> using namespace std; #define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define mp make_pair #define pb push_back #define ft first #define sc second #define ll long long #define pii pair<int, int> #define count_bits __builtin_popcount //#define int ll int n, m, a[21], b[21]; int sum[21]; //bool vm[21][(1ll<<20)-1 ]; vector<int> msk[21]; void complete(int ac, int ind, int pt, int x){ if(x>sum[pt]){ return; } if(x==sum[pt]){ msk[pt].pb(ac); return; } if(ind>20){ return; } complete(ac, ind+1, pt, x); if( (ac&(1ll<<(ind-1)) )==0 ){ complete(ac|(1ll<<(ind-1)), ind+1, pt, x+b[ind]); } return; } void build(){ msk[0].pb(0); for(int i=0; i<n; i++){ for(auto ac:msk[i]){ complete(ac, 1, i+1, sum[i]); } } } int32_t main(){ INIT cin>>n>>m; for(int i=1; i<=n; i++){ cin>>a[i]; sum[i]=sum[i-1]; sum[i]+=a[i]; } for(int i=1; i<=m; i++){ cin>>b[i]; } build(); /* cout<<msk[n].size()<<"sz\n"; for(auto c:msk[n]){ cout<<c<<"\n"; } */ if(msk[n].size()>0){ cout<<"YES\n"; } else{ cout<<"NO\n"; } 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...