제출 #525060

#제출 시각아이디문제언어결과실행 시간메모리
525060Dilshod_Imomov은행 (IZhO14_bank)C++17
71 / 100
1092 ms5024 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 ) { cout << "YES"; exit(0); } for ( int msk = 0; msk < (1 << m); msk++ ) { int cnt = 0; for ( int j = 0; j < m; j++ ) { if ( (msk >> j) & 1 ) { cnt += b[j]; } } if ( cnt == a[i] && !(msk & mask) ) { rec(i + 1, msk | mask); } } } 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]; } rec( 1, 0 ); cout << "NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...