제출 #525056

#제출 시각아이디문제언어결과실행 시간메모리
525056Dilshod_Imomov은행 (IZhO14_bank)C++17
19 / 100
61 ms5056 KiB
# include <bits/stdc++.h> # define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) // # define int long long # define fi first # define se second using namespace std; const int N = 2e5 + 7; const int mod = 1e9 + 7; // const int INF = 1e18 + 7; int a[N], b[N], n, m; vector < int > vc[N]; string ans = "NO"; void rec( int i, int mask ) { if ( i == n + 1 ) { ans = "YES"; cout << "YES"; exit(0); } for ( auto msk: vc[i] ) { if ( (msk & mask) == 0 ) { rec( i + 1, msk | mask ); return; } } } int32_t main() { speed; cin >> n >> m; for ( int i = 1; i <= n; i++ ) { cin >> a[i]; } for ( int i = 0; i < m; i++ ) { cin >> b[i]; } for ( int i = 1; i <= n; i++ ) { for ( int mask = 0; mask < (1 << m); mask++ ) { int cnt = 0; for ( int j = 0; j < m; j++ ) { if ( (mask >> j) & 1 ) { cnt += b[j]; } } if ( cnt == a[i] ) { vc[i].push_back(mask); } } } rec(1, 0); cout << ans; } /* 2 4 9 11 9 4 2 5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...