제출 #446844

#제출 시각아이디문제언어결과실행 시간메모리
446844bigDuck은행 (IZhO14_bank)C++14
0 / 100
1086 ms4400 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 t, n, m, a[30], b[30]; int dp[1ll<<20 ]; int sum[1ll<<20]; int32_t main(){ INIT cin>>n>>m; for(int i=1; i<=n; i++){ cin>>a[i]; } for(int i=1; i<=m; i++){ cin>>b[i]; sum[1ll<<(i-1)]=b[i]; } for(int B=1; B<(1ll<<m); B++){ sum[B]=sum[B&(-B)]+sum[B^( (B&(-B)) )]; } for(int B=1; B<(1ll<<m); B++){ for(int s=B; s>0; s=(s-1)&B){ if( (dp[B^s]==0) && (s<B) ){ continue; } if(sum[s]==a[dp[B^s]+1]){ dp[B]=dp[s]+1; break; } } if(dp[B]==n){ cout<<"YES"; return 0; } } 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...